ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL servermysql
D:\Wamp\mysql-5.6.21\bin>mysql.exe -uroot -p Enter password: ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL server
此處是root帳戶沒有本地數據庫的訪問權限,因此沒法鏈接數據庫,須要使用grant給root帳戶受權。sql
受權以前須要登陸到數據庫,使用skip-grant-tables參數數據庫
skip-grant-tables 顧名思義,數據庫啓動的時候 跳躍權限表的限制,不用驗證密碼,直接登陸。安全
編輯 my.ini,在[mysqld]的段中加上一句:skip-grant-tables socket
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock skip-name-resolve skip-grant-tables
臨時解決方案,亦能夠用於忘記mysql root用戶密碼時使用,安全性也比較難以保證。ide
而後登錄到root帳戶,此時不須要輸入密碼就能夠進入,而後grant受權this
mysql> grant all privileges on *.* to root@'localhost' identified by "123456";
若是此處報錯 ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statementspa
只須要刷新權限就行,flush privileges;code
而後再執行受權命令就好了。server
最後記得在配置文件中刪除 skip-grant-tables 參數,而後重啓MySQL服務。