7、wsl中mysql安装
apt update
apt install -y mysql-server mysql-client libmysqlclient-dev
usermod -d /var/lib/mysql/ mysql
安装完毕后重启mysql
服务
service mysql restart
# 修改配置文件 /etc/mysql/mysql.conf.d/mysqld.cnf
$ vi /etc/mysql/mysql.conf.d/mysqld.cnf
# bind-address = 0.0.0.0
# 登录MySQL
$ mysql -uroot -p
# 新增用户并允许远程访问
mysql> GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%'IDENTIFIED BY '密码' WITH GRANT OPTION;
?
mysql> update mysql.user set authentication_string=PASSWORD('密码'), plugin='mysql_native_password' where user='root';
?
?
# 刷新
mysql> flush privileges;
# 重启MySQL服务
$ service mysql restart