MySQL error:ERROR 1130 (HY000): Host ‘::1’ is not allowed to connect to this MySQL server
该错误具体的表现如下所示:
1 2 3 4 5 6 7 |
PS G:\搜狗高速下载\mysql-5.7.10-winx64\bin> .\mysql.exe -u admin -p Enter password: ****** ERROR 1130 (HY000): Host '::1' is not allowed to connect to this MySQL server PS G:\搜狗高速下载\mysql-5.7.10-winx64\bin> .\mysql.exe -h localhost -u admin -p Enter password: ****** ERROR 1130 (HY000): Host '::1' is not allowed to connect to this MySQL server PS G:\搜狗高速下载\mysql-5.7.10-winx64\bin> |
该错误的解决可以通过修改MySQL中的数据表:mysql.user的host字段修复:
1. 以skip-grant-tables方式启动MySQL服务(当前系统:MS Windows 7):
.\mysqld.exe –defaults-file=”G:\搜狗高速下载\mysql-5.7.10-winx64\my.ini” –console –skip-grant-tables
2. 修改mysql.user.host字段
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
mysql> select user,host from user; +-----------+-----------+ | user | host | +-----------+-----------+ | mysql.sys | localhost | | root | localhost | +-----------+-----------+ 2 rows in set (0.00 sec) mysql> mysql> update user set host='%'; Query OK, 2 rows affected (0.00 sec) Rows matched: 2 Changed: 2 Warnings: 0 mysql> select user,host from user; +-----------+------+ | user | host | +-----------+------+ | mysql.sys | % | | root | % | +-----------+------+ 2 rows in set (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> exit |
3. 以正常的方式启动MySQL:
.\mysqld.exe –defaults-file=”G:\搜狗高速下载\mysql-5.7.10-winx64\my.ini”
4. 再次登录:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
PS G:\搜狗高速下载\mysql-5.7.10-winx64\bin> .\mysql.exe -u root -p Enter password: ****** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.10 MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> select user,host from mysql.user; +-----------+------+ | user | host | +-----------+------+ | mysql.sys | % | | root | % | +-----------+------+ 2 rows in set (0.00 sec) mysql> exit Bye PS G:\搜狗高速下载\mysql-5.7.10-winx64\bin> |
这样,就正常了。
————————————————————
Done。