有兩種解決方法:mysql
1.受權法sql
GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; // %:表示從任何主機鏈接到mysql服務器數據庫
FLUSH PRIVILEGES;服務器
或者ide
GRANT ALL PRIVILEGES ON *.* TO 'user'@'116.30.70.187' IDENTIFIED BY 'password' WITH GRANT OPTION;//表示從指定ip從任何主機鏈接到mysql服務器ip
FLUSH PRIVILEGES;it
2.該表法class
多是你的賬號不容許從遠程登錄,只能在localhost。這個時候只要在localhost的那臺電腦,登入MySQL後,更改 "mysql" 數據庫裏的 "user" 表裏的 "host" 項,從"localhost"改稱"%"
mysql -u root -p
mysql>use mysql;
mysql>update user set host = '%' where user = 'root' and host='localhost';
mysql>select host, user from user;
而後重啓MySQL服務。或再執行 執行一個語句 mysql>FLUSH RIVILEGES 使修改生效。date
這樣就大功告成,就能夠遠程連接數據庫了select
————————————————