解决# 1130 Host 'localhost' is not allowed to connect to this MySQL server
新安装的Wampserver,但用MySQL-Front连接时出现错误:
SQL 执行错误 # 1130. 从数据库的响应:
Host ‘localhost’ is not allowed to connect to this MySQL server
解决方法如下:
1.停止mysql服务,如果不会可以直接Wampserver所有服务或者退出Wampserver。
2.用cmd打开一个命令行窗口,切换到mysql的安装目录,例如我的路径是:
D:>cd D:\wamp\bin\mysql\mysql5.7.14\bin
运行 mysqld --skip-grant-tables
D:\wamp\bin\mysql\mysql5.7.14\bin>mysqld --skip-grant-tables
不要关闭cmd,因为这是启动的服务。
(如果弹出防火墙访问提示对话框,选择允许访问)
3.再用cmd打开一个命令行窗口
D:>cd D:\wamp\bin\mysql\mysql5.7.14\bin
运行 mysql -u root -p
输入密码
use mysql;
mysql> delete from user where user=‘root’;
mysql> CREATE USER ‘root’@‘localhost’ IDENTIFIED BY ‘password’;
//如果提示:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot exe
//解决办法,在命令行输入:flush privileges;
//注:password用自己的密码替换
mysql> GRANT ALL PRIVILEGES ON . TO ‘root’@‘localhost’ WITH GRANT OPTION;
mysql> CREATE USER ‘root’@‘%’ IDENTIFIED BY ‘password’;
mysql> GRANT ALL PRIVILEGES ON . TO ‘root’@‘%’ WITH GRANT OPTION;
4.停掉命令行的服务,重新启动Wampserver里的MySQL。