報錯:1130-host ... is not allowed to connect to this MySql server,1130-hostallowed

來源:互聯網
上載者:User

報錯:1130-host ... is not allowed to connect to this MySql server,1130-hostallowed

解決方案:

1。 改表法。

可能是你的帳號不允許從遠程登陸,只能在localhost。這個時候只要在localhost的那台電腦,登入mysql後,更改 "mysql" 資料庫裡的 "user" 表裡的 "host" 項,從"localhost"改稱"%"

mysql -u root -pvmwaremysql>use mysql;

mysql>update user set host = '%' where user = 'root';

mysql>select host, user from user;

2. 授權法。

例如,你想myuser使用mypassword從任何主機串連到mysql伺服器的話。

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH   PRIVILEGES;

如果你想允許使用者myuser從ip為192.168.1.6的主機串連到mysql伺服器,並使用mypassword作為密碼

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH   PRIVILEGES;

如果你想允許使用者myuser從ip為192.168.1.6的主機串連到mysql伺服器的dk資料庫,並使用mypassword作為密碼

GRANT ALL PRIVILEGES ON dk.* TO 'myuser'@'192.168.1.3' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

FLUSH   PRIVILEGES;

我用的第一個方法,剛開始發現不行,在網上查了一下,少執行一個語句 mysql>FLUSH RIVILEGES 使修改生效.就可以了

另外一種方法,不過我沒有親自試過的,在csdn.net上找的,可以看一下.

在安裝mysql的機器上運行:

1、d:\mysql\bin\>mysql   -h   localhost   -u   root //這樣應該可以進入MySQL伺服器

2、mysql>GRANT   ALL   PRIVILEGES   ON   *.*   TO   'root'@'%'   WITH   GRANT   OPTION //賦予任何主機訪問資料的許可權

3、mysql>FLUSH   PRIVILEGES //修改生效

4、mysql>EXIT //退出MySQL伺服器

這樣就可以在其它任何的主機上以root身份登入啦!

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.