MySQL · error reference
MySQL ERROR 1040: Too many connections
ERROR 1040 (HY000): Too many connections
MySQL has run out of connection slots. It keeps one spare for an administrator, which is how you get in to fix it.
What the database is telling you
The server already has max_connections clients (151 by default). MySQL allows one connection beyond that for an account with CONNECTION_ADMIN (SUPER on older versions), so an administrator can still log in while everyone else is refused.
Why it shows up in a migration
Migrations add parallel connections on top of an application's pool. On a server sized for its usual load, that pushes it over the edge — typically at the moment the copy fans out across tables.
Common causes
- Connections left Sleeping by application pools or scripts that never close them.
- wait_timeout at its default of eight hours, so abandoned connections linger.
- Too many services each holding their own pool against one server.
- max_connections set low for the workload.
How to fix it
- 1
Log in with an admin account (the spare slot) and see what holds the connections.
SHOW GLOBAL STATUS LIKE 'Threads_connected'; SELECT user, host, command, time FROM information_schema.PROCESSLIST ORDER BY time DESC;
- 2
End a long-sleeping connection by its id.
KILL 12345;
- 3
Let the server close abandoned connections sooner.
SET GLOBAL wait_timeout = 600;
- 4
Raise the limit only once you know the server has memory for it — and persist it in my.cnf, since SET GLOBAL is lost on restart.
SET GLOBAL max_connections = 300;
What DBShifts does about it
Connection diagnosis reports this as the database being out of connection slots. Airlock reuses one pooled connector per connection and closes it after five idle minutes, so agents do not add a connection per question.
Connection diagnosis · gateway connection pool
Connecting a database?
Add the database to DBShifts and the connection is tested on the spot. If it fails, you get which of these errors it is and what to change — not the driver's raw message. Once it connects, browse it, migrate it, or let an AI agent read it through the gateway with sensitive columns masked.