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服务。