Mysql连接报错 Can't connect to MySQL server on 'ip' (10060)

在购买服务器且安装了Mysql之后,并且安全组和防火墙都开放了端口,但是还是无法连接
原因就是mysql设置的就是只有本机可以连接

解决办法

# 1. 登录服务器,在服务器上登录mysql
# 2. 使用user这个库
use mysql;
# 3. 查看root账户
select host,user from user;

可以看到,只有localhost也就是本机可以连接root账户,所以需要更改

# 4. 更改权限
update user set host='%' where user='root';
# 5. 刷新一下
flush privileges;

之后就可以解决问题了

posted @ 2021-07-03 18:19  蜡笔没有大象  阅读(489)  评论(0)    收藏  举报