If you are getting MySQL connection error ” Host ” is blocked because of many connection errors; unblock with ‘mysqladmin flush-hosts’ ” this means your application such PHP or Java unable to connect MySQL server because unable to
authenticate with the application or application is trying too many connections to MySQL in a rate where MySQL server can’t serve all the requests.
There are some common error for too many connection error in MySQL are :
- Server is down
- Network issue
- Authentication issue
- Maximum connection error allowed
But above mention error it is sure sign application connections to MySQL is logging a lot of error connection due to some reason.
This error mostly happens on very busy websites where high amount of separate connection are used. Mostly this error happens in PHP based application where mysql_pconect(): is selected in favour of the proved working mysql_connect();
Before increasing default set of max connection error first check how many max connection error are set in MySQL. Type the below command to check this:
mysql> SHOW VARIABLES LIKE '%error%'; +——————–+————————————————————-+ | Variable_name | Value | +——————–+————————————————————-+ | error_count | 0 | | log_error | /var/log/mysql//mysqld.log | | max_connect_errors | 10000 | | max_error_count | 64 | | slave_skip_errors | OFF | +——————–+————————————————————-+
You can debug the max connection error reached problem using below command:
mysql> SHOW PROCESSLIST;
Now to solve the above MySQL error you can edit /etc/my.cnf file like below :
# vim /etc/my.cnf ....... max_connect_errors = 100000 wait_timeout = 60 ....
If above mention high values is still not high enough you can raise MySQL config connection timeout:
max_connect_errors = 100000000
You can also set max_connect_errors variable without making it permanent using below command:
SET GLOBAL max_connect_errors
If you want to fix this error temporary you can try below command:
# mysqladmin flush-hosts
From MySQL Cli:
mysql> FLUSH HOSTS;
Thanks:)
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment