MySQL查看当前用户及允许登录的IP:
#https://www.haiyun.me
select host,user from mysql.user;
+-----------+--------+
| host | user |
+-----------+--------+
| 127.0.0.1 | root |
| localhost | root |
+-----------+--------+
2 rows in set (0.00 sec)
新建用户允许特定IP连接,%允许所有。
grant all privileges on *.* to 'root'@'%' identified by 'password' ;
或更新现用户host信息:
update mysql.user set host = '%' where user = 'root';
刷新权限:
flush privileges;
如果还不能连接检查防火墙是否开放相应端口,mysql监听ip地址,mysql是否禁用通过tcp连接。