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