Home >Database >Mysql Tutorial >MySQL错误:Can't connect to MySQL server (10060)

MySQL错误:Can't connect to MySQL server (10060)

WBOY
WBOYOriginal
2016-06-07 17:14:251287browse

当远程连接MySQL数据库的时候显示Can

当远程连接MySQL数据库的时候显示Can't connect to MySQL server (10060),我们从以下几个方面入手,找出错误的原因:

1.网络不通。

检查能不能ping通。

2.防火墙设置。

防火墙是否放过mysql的进程,是否屏蔽了mysql的3306端口。

3.mysql的账户设置。

mysql账户是否不允许远程连接。如果无法连接可以尝试以下方法:

mysql -u root -p    //登录MySQL

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;     //任何远程主机都可以访问数据库

mysql> FLUSH PRIVILEGES;    //需要输入次命令使修改生效

mysql> EXIT    //退出

也可以通过修改表来实现远程:

mysql -u root -p

mysql> use mysql;

mysql> update user set host = '%' where user = 'root';

mysql> select host, user from user;

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn