MySQLをWSLから使う

WSLで

$ sudo apt install mysql-server mysql-client

MySQLをインストールして、起動しようとすると、

$ sudo mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:
Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

とか、

$ service mysql start
df: /var/lib/mysql/.: Permission denied
 * /etc/init.d/mysql: ERROR: The partition with /var/lib/mysql is too full!

とか

$ sudo service mysql start
 * Starting MySQL database server mysqld                                                                                No directory, logging in with HOME=/
mkdir: cannot create directory ‘//.cache’: Permission denied
  • su: 19: /etc/profile.d/wsl-integration.sh: cannot create //.cache/wslu/integration: Directory nonexistent
[ OK ]

とかなってうまくいかない。

ので、Stackoverflowでみつけたやり方でやった。多分WSLだとsockがないとか、うまく作れないのだろう。

stackoverflow.com


MySQLの一通りの使い方。
tomato-develop.com