天天看點

Host is not allowed to connect to this MySQL server錯誤的解決辦法

錯誤描述

我先做了這些工作:伺服器用的 Windows Server 2012。配置好伺服器上的MySQL。防火牆允許mysqld.exe 。

然後在我自己的電腦上用 workbench 連接配接伺服器上的 MySQL 發現無法連接配接。提示錯誤: Host ‘xxx.xxx.xxx.xxx’ is not allowed to connect to this MySQL server 。其中 ‘xxx.xxx.xxx.xxx’ 是我自己的電腦的IP。

解決方法

遠端桌面連接配接到伺服器。調用

mysql -u root -p

指令打開用戶端,連接配接資料庫。執行如下指令并得到傳回結果:

mysql> use mysql
mysql> select t.host from user t where t.user='root';
+--------------+
|  host        |
+--------------+
|  localhost   |
+--------------+
           

這個傳回結果說明現在 root 使用者隻允許在伺服器的本地登入。

執行如下指令:

然後重新開機 MySQL 服務就可以了。

原文位址