1、sudo apt update
2、sudo apt install mysql-server
3、验证是否正确运行
sudo systemctl status mysql
4、
![](https://img.haomeiwen.com/i13186820/5a8d98b8a8934f95.png)
5、sudo mysql 进入mysql命令行
6、show databases=>use mysql=>show tables=>select host,user,plugin from user;
把root那条改为host=‘%’
执行这条命令修改密码:alter user 'root'@'%' identified with mysql_native_password by '这里填密码';
7、cd /etc/mysql/mysql.conf.d
sudo vim mysqld.cnf
将其中bind-address = 127.0.0.1注释掉。
8、/etc/init.d/mysql restart 重启mysql服务
9、如果以上还不能链接,查看3306端口是否被禁
网友评论