ERROR 1130 (HY000): Host '' is not allowed to connect to this MySQL server
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19101243/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ERROR 1130 (HY000): Host '' is not allowed to connect to this MySQL server
提问by Tampa
Why oh why can I not connect to mysql?
为什么哦为什么我无法连接到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
In my.cnf I have the below
在 my.cnf 我有以下内容
# 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
I also ran the below...
我也跑了下面...
'UPDATE mysql.user SET Password = PASSWORD('test101') WHERE User = 'root';
FLUSH PRIVILEGES;
I can access on the host machine using mysql -u root -ptest101 but not using mysql -u root -ptest101 -h xxx.xxx.xxx.xxx
我可以使用 mysql -u root -ptest101 在主机上访问,但不能使用 mysql -u root -ptest101 -h xxx.xxx.xxx.xxx
Wow...why is this happening? I am n ubuntj 12.04
哇……为什么会这样?我是 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)
回答by newfurniturey
Your root
account, and this statement applies to any account, may only have been added with localhost access (which is recommended).
您的root
帐户(此声明适用于任何帐户)可能只添加了 localhost 访问权限(推荐)。
You can check this with:
您可以通过以下方式检查:
SELECT host FROM mysql.user WHERE User = 'root';
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.
如果您只看到带有localhost
和 的结果127.0.0.1
,则无法从外部源进行连接。如果您看到其他 IP 地址,而不是您正在连接的 IP 地址 - 这也是一种指示。
You will need to add the IP address of each system that you want to grant access to, and then grant privileges:
您需要添加要授予访问权限的每个系统的 IP 地址,然后授予权限:
CREATE USER 'root'@'ip_address' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip_address';
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:
如果你看到%
,那么,还有另一个问题,因为那是“任何远程源”。但是,如果您确实希望任何/所有系统通过 root 连接,请使用%
通配符授予访问权限:
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;
回答by Ravi Garg
Following two steps worked perfectly fine for me:
以下两个步骤对我来说非常有效:
Comment out the bind address from the file
/etc/mysql/my.cnf
:#bind-address = 127.0.0.1
Run following query in phpMyAdmin:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; FLUSH PRIVILEGES;
从文件中注释掉绑定地址
/etc/mysql/my.cnf
:#bind-address = 127.0.0.1
在 phpMyAdmin 中运行以下查询:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; FLUSH PRIVILEGES;
回答by siripurapu venkatarao
$mysql -u root --host=127.0.0.1 -p
mysql>use mysql
mysql>GRANT ALL ON *.* to root@'%' IDENTIFIED BY 'redhat@123';
mysql>FLUSH PRIVILEGES;
mysql> SELECT host FROM mysql.user WHERE User = 'root';
回答by HappyCoder
mysql> CREATE USER 'name'@'%' IDENTIFIED BY 'passWord'; Query OK, 0 rows affected (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON .TO 'name'@'%'; Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> CREATE USER 'name'@'%' IDENTIFIED BY 'passWord'; 查询正常,0 行受影响(0.00 秒)
mysql> 授予所有权限。命名'@'%'; 查询正常,0 行受影响(0.00 秒)
mysql> 刷新特权;查询正常,0 行受影响(0.00 秒)
mysql>
- Make sure you have your name and % the right way round
- Makes sure you have added your port 3306 to any firewall you may be running (although this will give a different error message)
- 确保你有你的名字和 % 正确的方式
- 确保您已将端口 3306 添加到您可能正在运行的任何防火墙(尽管这会给出不同的错误消息)
hope this helps someone...
希望这可以帮助某人...
回答by peterpan1215
For those who are able to access cpanel, there is a simpler way getting around it.
对于那些能够访问 cpanel 的人来说,有一种更简单的方法可以绕过它。
log in cpanel => "Remote MySQL" under DATABASES section:
Add the IPs / hostname which you are accessing from
done!!!
登录 cpanel => DATABASES 部分下的“远程 MySQL”:
添加您正在访问的 IP/主机名
完毕!!!
回答by TomoMiha
Go to PhpMyAdmin, click on desired database, go to Privilages tab and create new user "remote", and give him all privilages and in host field set "Any host" option(%).
转到 PhpMyAdmin,单击所需的数据库,转到权限选项卡并创建新用户“远程”,并为他提供所有权限并在主机字段中设置“任何主机”选项(%)。
回答by salim333
there an easy way to fix this error
有一种简单的方法可以解决此错误
just replace the files on the folder : C:\xampp\mysql\data\mysql
只需替换文件夹中的文件: C:\xampp\mysql\data\mysql
with the files on : C:\xampp\mysql\backup\mysql
文件在: C:\xampp\mysql\backup\mysql