环境
windows10 + WLS
安装
sudo apt update
sudo apt install mysql-server
初始化及启动
出错
执行初始化命令时也发生错误:
sudo mysqld_safe --initialize --user=mysql
报错:
Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, can't create lock file /var/run/mysqld/mysqlx.sock.lock'
执行启动命令也出现同样错误:
sudo mysqld_safe --user=mysql &
报错:
Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, can't create lock file /var/run/mysqld/mysqlx.sock.lock'
解决
创建目录/var/run/mysqld :
sudo mkdir /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
sudo chmod 750 /var/run/mysqld
创建目录后再次启动:
sudo mysqld_safe --user=mysql &
测试连接:
sudo mysqladmin version
结果如下:
lcy@LAPTOP-4C7M093G:/usr/local$ sudo mysqladmin version
[sudo] password for lcy:
mysqladmin Ver 8.0.26-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version 8.0.26-0ubuntu0.20.04.2
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 53 sec
Threads: 2 Questions: 2 Slow queries: 0 Opens: 117 Flush tables: 3 Open tables: 36 Queries per second avg: 0.037
参考
MySQL :: MySQL Installation Guide :: 9.1 Initializing the Data Directory
MySQL :: MySQL Installation Guide :: 9.2 Starting the Server
网友评论