ERROR 1130 (HY000): Host #39;#39; is not allowed to connect to this MySQL server(ERROR 1130 (HY000): Host is not allowed to connect to this MySQL server)
问题描述
为什么哦为什么我连不上mysql?
Why oh why can I not connect to mysql?
mysql -u root -ptest101 -h xxx.xxx.xxx.xxx
ERROR 1130 (HY000): Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server
在 my.cnf 中有以下内容
In my.cnf I have the below
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0
我还运行了以下...
'UPDATE mysql.user SET Password = PASSWORD('test101') WHERE User = 'root';
FLUSH PRIVILEGES;
我可以使用 mysql -u root -ptest101 在主机上访问,但不能使用 mysql -u root -ptest101 -h xxx.xxx.xxx.xxx
I can access on the host machine using mysql -u root -ptest101 but not using mysql -u root -ptest101 -h xxx.xxx.xxx.xxx
哇……为什么会这样?我是 ubuntj 12.04
Wow...why is this happening? I am n ubuntj 12.04
mysql> SELECT host FROM mysql.user WHERE User = 'root';
+---------------------------------------------+
| host |
+---------------------------------------------+
| % |
| 127.0.0.1 |
| ::1 | |
| localhost |
+---------------------------------------------+
5 rows in set (0.00 sec)
推荐答案
您的 root
帐户,此声明适用于任何帐户,可能只添加了 localhost 访问权限(推荐).
Your root
account, and this statement applies to any account, may only have been added with localhost access (which is recommended).
您可以通过以下方式检查:
You can check this with:
SELECT host FROM mysql.user WHERE User = 'root';
如果您只看到 localhost
和 127.0.0.1
的结果,则无法从外部源进行连接.如果您看到其他 IP 地址,但不是您所连接的 IP 地址 - 这也是一种指示.
If you only see results with localhost
and 127.0.0.1
, you cannot connect from an external source. If you see other IP addresses, but not the one you're connecting from - that's also an indication.
您需要添加要授予访问权限的每个系统的 IP 地址,然后授予权限:
You will need to add the IP address of each system that you want to grant access to, and then grant privileges:
CREATE USER 'root'@'ip_address' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip_address';
如果您看到 %
,那么,还有另一个问题,因为它是任何远程源".但是,如果您确实希望通过 root 连接任何/所有系统,请使用 %
通配符授予访问权限:
If you see %
, well then, there's another problem altogether as that is "any remote source". If however you do want any/all systems to connect via root, use the %
wildcard to grant access:
CREATE USER 'root'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
最后,重新加载权限,您应该可以进行远程访问了:
Finally, reload the permissions, and you should be able to have remote access:
FLUSH PRIVILEGES;
这篇关于ERROR 1130 (HY000): Host '' is not allowed to connect to this MySQL server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ERROR 1130 (HY000): Host '' is not allowed to connect to this MySQL server
- 更改自动增量起始编号? 2021-01-01
- SQL 临时表问题 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01