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;

##5.7
mysql> update mysql.user set authentication_string=PASSWORD('密码'), plugin='mysql_native_password' where user='root';

##8.0以上
​alter user 'root'@'localhost' identified with mysql_native_password by '密码';

# 刷新
mysql> flush privileges;
# 重启MySQL服务
$ service mysql restart

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

posted @ 2021-07-30 09:32  嘎嘎6866  阅读(263)  评论(0)    收藏  举报