1.网络是否畅通 ping一下服务器
2.查看防火墙3306端口
netstat -an|grep 3306;
如果结果显示:
127.0.0.1:3306
代表只允许本地访问
修改my.cnf
注释掉:bind-address = 127.0.0.1
然后重启mysql:sudo /etc/init.d/mysql restart;
再查看
3. sudo vi /etc/mysql/my.cnf
打开my.cnf查看 bind-address = 127.0.0.1是否注释掉,不注释代表绑定本地ip,
其他客户端就 不能访问
4.赋权限
进入mysql
mysql -u root -p;
grant all privileges on *.* to root@'%' identified by "xxx" with grant option;
flush privileges;
就是这几个了,我是因为在my.cnf下没有注释