mysql遠程無法登陸出現ERROR 2003 (HY000)…解決方法

Q: 當在另一臺機器上登錄MySQL時出現如下錯誤:

ERROR 2003 (HY000): Can't connect to MySQL server on 'x.x.x.x' (111)

A: 原因是MySQL考慮到安全因素,默認配置隻讓從本地登錄

打開 /etc/mysql/my.cnf 文件,找到 bind-address = 修改為 bind-address =


重啟mysql : sudo /etc/init.d/mysql restart


> I've already check my /etc/my.cnf file for a "binding"
> line.  Its not
> there.  I also found an item online that indicated
> adding:

Look for the option "skip-networking". This disables TCP/IP so the
server only accepts local connections via the Unix socket. This sounds
like your situation.
Note that a "could not connect" error means just that. If the problem
was related to user privileges you would get an "access denied" error.

Q: 還一種情況出現類似下面的錯誤:

ERROR 1045 (28000): Access denied for user 'test'@'x.x.x.x' (using password: NO)

A: 原因是沒有給登錄用戶名設置遠程主機登錄的權限。

在本地用 root 登錄: mysql -u root -p

修改 MySQL 數據庫中 user 表中 對應用戶名的 Host 字段,將 localhost 改為 %

use mysql;

update user set Host = '%' where User = 'username';

You May Also Like