Trouble Connecting to MySQL Database

If a machine isn’t able to connect to the MySQL database there are a number of possible solutions.

  1. Hard drive full

    1. if the drive the MySQL database is stored on is full then MySQL will generate all kinds of errors

  2. MySQL user definition

    1. is the user account limited to specific hosts or does it allow connections from all hosts?

    2. is the user password use correct?

  3. Connection limits

    1. MySQL has settings that limit the number of open connections. Once this limit is exceeded further requests for additional connections are blocked.

  4. Too many connection errors

    1. If a specific machine has too many connection errors it is auto-blocked by MySQL

Connection Limits

To check the current limit on the number of allowed connections:

SHOW VARIABLES LIKE '%max_connect%';

If you need to check the status on the number of connections used:

SHOW STATUS LIKE '%conn%';

Too Many Connection Errors

MySQL Error Number 1129

If a specific host tries and fails to connect too many times (wrong user/password) then MySQL will block that machine.

This article describes the situation: https://stackoverflow.com/questions/36272953/error-1129-host-blocked-because-of-many-connection-error

Error 1129 means MySQL's crude anti-cybercriminal feature has been activated: programs running on the same machine you're using have tried and failed to connect many times (100 by default). When that happens MySQL concludes the machine is compromised (or running amok) and refuses to accept any more connections from it.

To reenable blocked hosts you use the flush hosts command. For help see the MySQL Docs for flush...

flush hosts;