首先查看端口连接性:
netstat -apn | grep 3306
修改绑定端口:
vi /etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 127.0.0.1 修改为0.0.0.0
进入mysql
use mysql;
select host,user,plugin from user;
可以看到plugin是auth_socket
更改为caching_sha2_password即可
alter user 'root'@'%' identified with caching_sha2_password by '你的密码';
修改后远程连接root成功