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

https://blog.csdn.net/weixin_43530726/article/details/91303898