解决mysql只能通过localhost登录的问题(有权限)

今天自建了一个库,在关闭防火墙后仍然无法用ip访问,最后解决如下:

1.增加远程访问权限

grant all privileges on *.* to 'root'@'localhost' identified by 'xxx';

2.去掉/etc/mysql/my.cnf内的127.0.0.1绑定那一行
3.最后重启解决

/etc/init.d/mysql stop

/etc/init.d/mysql start

 其中第3步最好做一下,看网上其他人不做就可以生效,但是我直到重启后才生效(Ubuntu)

原文地址:https://www.cnblogs.com/qooweds/p/7977839.html