MySQL 1158: Too many connections.

  1. Check the Current Number of Connections: Run the command to see the number of current connections and the maximum allowed connections.


SHOW VARIABLES LIKE "max_connections";
SHOW STATUS LIKE "Threads_connected";


  1. Identify the Source of Connections: Find out which user or host is opening so many connections. This can help identify if it's an application issue or unauthorized access.


SHOW PROCESSLIST;

  1. Increase Max Connections Temporarily: If your server can handle more connections and you need an immediate fix, increase the `max_connections` setting.


SET GLOBAL max_connections = 1000; -- Adjust the number based on your server capacity

  1. Close Idle Connections: Look for idle connections that can be closed. If you find any idle connections from the `SHOW PROCESSLIST` output, you can kill them using:


KILL [connection id]; -- Replace [connection id] with the actual ID from SHOW PROCESSLIST

  1. Flush Hosts: If the error is due to blocked connections because of many connection errors, you can flush the hosts.


FLUSH HOSTS;

Never debug

MySQL

manually again

Let Dr. Droid create custom investigation plans for your infrastructure.

Book Demo
Automate Debugging for
MySQL
See how Dr. Droid creates investigation plans for your infrastructure.

MORE ISSUES

Made with ❤️ in Bangalore & San Francisco 🏢

Doctor Droid