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


谷歌了一下之后,原來是在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;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM