Tips & Tricks

How to flush-hosts in MySQL

Probably many of you have met the MySQL max connections issue and that you need to do flush-hosts. This tutorial will explain how to do it.

Firstly you need to have the admin user of your MySQL server. In most cases it is root.

Login through SSH and execute the following command:
mysqladmin -uroot -p flush-hosts

This will prompt for password and then will flush the hosts. If your administrative user is different change root with the name of your user.

Why does it happen?
Mostly it happens for 2 reasons:
1. Your scripts are not closing the connections to MySQL once they are done.
2. MySQL allows 250 connections by the default. If this is not enough for your needs you can always edit the /etc/my.cnf configuraton file and increase this value.

Leave a Reply