如何在 WSL 中使用 MySQL(Windows 子系统 Linux)?

How to use MySQL in WSL (Windows Subsystem for Linux)?

如何在不为 Windows.

安装任何单独的 MySQL 客户端的情况下在 wsl 中使用 mysql

在您的 bash 命令行中:

sudo apt-get update
sudo apt-get install mysql-server
mysql_secure_installation

以下是我如何通过 WSL 访问安装在 Windows 10 中的 MySQL:

1.创建具有远程访问权限的用户

CREATE USER 'newuser'@'%' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'%';
FLUSH PRIVILEGES;

2。更新 mysql.ini

bind-address=0.0.0.0
# skip-external-locking

3。使用本地 IP

测试连接
>mysql -h192.xxx.xx.xx -P 3306 -unewuser -p