Can't connect to MySQL server on '' (10060)


客户端远程连接部署在linux服务器的mysql出现以上错误,总大概分为以下3点

主要有3个原因:

1、检查网络是否可以ping通,这个就不说了。

2、mysql授权表里没有远程机器的权限

方法一、本地登入mysql,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,将"localhost"改为"%"

#mysql -u root -proot

mysql>use mysql;

mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
方法二、直接授权(推荐)

从任何主机上使用root用户,密码:youpassword(你的root密码)连接到mysql服务器:

grant all privileges on *.* to 'root'@'%' identified by '登陆密码'

flush privileges;

3、防火墙禁止3306端口,以iptable为例
vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306-j ACCEPT  
service iptables restart

 iptables设置
1) 重启后生效 
开启: chkconfig iptables on 
关闭: chkconfig iptables off 


2) 即时生效,重启后失效 
开启: service iptables start 
关闭: service iptables stop
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章