3

here is the code

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

and I get back (by echo)

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

and here is the text in error log file

[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

what's wrong?
what should I do?

mk rowling
  • 203
  • 1
  • 12

1 Answers1

0

Your IP is blocked because you have attempted to log-into the MySQL server too many times without the correct username/password, as per the error:

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

To fix, log-into your MySQL server console and execute a FLUSH HOSTS command.

If this is on shared hosting, deleting and recreating the database will work. In my own experience many web-hosts tend to say it's your MySQL database, it's your problem. Unless you want to wait a long time for your host to unblock your IP, I'd advise exporting all data in the database and deleting the database, recreating the database and importing your data from the file you exported.

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.

If the 'FLUSH HOSTS' command does not work, change the password to connect to the MySQL server and it should then connect.

AStopher
  • 4,207
  • 11
  • 50
  • 75
  • The issue is basically failure message for a mysql connection. The server can't locate the MySQL DB and returns this error. For you the issue is the host is unable to resolve my server name (myservername.com) and it fails to connect. One solution is to change the server name to `localhost` and use the connect method to connect. – DesignerMind Nov 04 '14 at 22:22
  • @DesignerMind This question was closed as a 'duplicate' shortly after I submitted my answer, I didn't upvote/downvote/flag the question. This error message ***does not relate to a 'server not found'***, it means the `max_connect_errors` variable for the MySQL server has been exceeded- it's a security feature. – AStopher Nov 04 '14 at 22:25