1. 程式人生 > >ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.33.10' (111) 解決方法

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.33.10' (111) 解決方法

working username 127.0.0.1 sans per 註釋 bsp 用戶 host

谷歌了一下之後,原來是在mysql的my.cnf中有下面一段代碼:

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address           = 127.0.0.1  #這裏默認監聽本地localhost



如果要讓mysql監聽到其他的地址,可以將bind-address = 127.0.0.1註釋掉。

或者將bind-address = 0.0.0.0監聽所有的地址

如果想讓192.168.10.83

能夠連接到本地的這個數據庫,要讓數據庫給其分配權限,登錄mysql,執行:(username 和 password是登錄mysql的用戶名和密碼)

GRANT ALL PRIVILEGES ON *.* TO username@192.168.10.83 IDENTIFIED BY password WITH GRANT OPTION;


如果要想所有的外部ip地址都能夠訪問使用mysql,可以執行下面:
GRANT ALL PRIVILEGES ON *.* TO username@% IDENTIFIED BY password WITH GRANT OPTION
;

之後執行刷新數據庫:

flush privileges;

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.33.10' (111) 解決方法