Host X is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’

For some reason, you might get these error when you execute the MySQL query,

Host '' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /home/mickgenie/public_html/wow.php on line 25
Unable to connect to mysql server

The quick fix but not permanent solution will be running the command as below,

mysqladmin flush-hosts

To fix the issue permanently, edit the file /etc/my.cnf.

Add the following line to the /etc/my.cnf below [mysqld]

set-variable = max_connect_errors=5000

Then restart the MySQL services.

Identify slow MySQL query

Sometimes, MySQL will make your server pain if you have user abusing it. Mick Genie will teach you to identify which MySQL database creating the problem to your server.

Actually MySQL can log all of the those query that taking longer time than certain seconds.

1. Login to the server as root.
2. Open your my.cnf with your editor.

vi /etc/my.cnf

3. In the [mysqld] section, add the line as below.

log-slow-queries = /var/log/mysql-slow.log
long_query_time = 3

this meant that the log will logged to /var/log/mysql-slow.log and the query time is 3 seconds.

4. Save the my.cnf by typing “:wq!” and press enter.
Continue reading Identify slow MySQL query