2014-11-04 81 views
2

这里是代码错误,同时连接到MySQL

<?php 
    $con = mysqli_connect("******.com","user","pass","db"); 
    echo mysqli_connect_error(); 
?> 

和我回去(由回声)

Host '*****************' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

,这里是在错误日志文件中的文本

[04-Nov-2014 21:30:22 UTC] PHP Warning: mysqli_connect(): (HY000/1129): Host '*******************' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /home/******/public_html/test.php on line 2

and

[04-Nov-2014 21:18:30 UTC] PHP Warning: mysqli_connect(): (28000/1045): Access denied for user 'user'@'******************' (using password: YES) in /home/*******/public_html/test.php on line 2

怎么了?
我该怎么办?

回答

0

你的IP被封锁,因为你已经尝试登录到MySQL服务器太多次不正确的用户名/密码,按错误:

Host '*****************' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'

要修复,登录到你的MySQL服务器控制台并执行FLUSH HOSTS命令。

如果这是共享主机,删除和重新创建数据库将工作。根据我自己的经验,许多网络主机往往会说你的MySQL数据库是,这是你的问题。除非你想等待你的主机解锁IP,否则我建议你导出数据库中的所有数据并删除数据库,重新创建数据库并从你导出的文件中导入数据。

From the official documentation:

The value of the max_connect_errors system variable determines how many successive interrupted connection requests are permitted. (See Section 5.1.4, “Server System Variables”.) After max_connect_errors failed requests without a successful connection, mysqld assumes that something is wrong (for example, that someone is trying to break in), and blocks the host from further connections until you issue a FLUSH HOSTS statement or execute a mysqladmin flush-hosts command.

By default, mysqld blocks a host after 10 connection errors. You can adjust the value by setting max_connect_errors at server startup:

shell> mysqld_safe --max_connect_errors=10000 & The value can also be set at runtime:

mysql> SET GLOBAL max_connect_errors=10000; If you get the Host 'host_name' is blocked error message for a given host, you should first verify that there is nothing wrong with TCP/IP connections from that host. If you are having network problems, it does you no good to increase the value of the max_connect_errors variable.

+0

问题基本上是一个MySQL连接失败的消息。服务器无法找到MySQL数据库并返回此错误。 对于您来说,问题是主机无法解析我的服务器名称(myservername.com)并且无法连接。一种解决方案是将服务器名称更改为'localhost'并使用连接方法进行连接。 – DesignerMind 2014-11-04 22:22:21

+0

@DesignerMind在我提交答案后不久,这个问题就以'重复'的方式被关闭了,我没有upvote/downvote/flag问题。这个错误信息***与'未找到服务器'***无关,这意味着MySQL服务器的'max_connect_errors'变量已被超过 - 这是一项安全功能。 – cybermonkey 2014-11-04 22:25:29