NinjaOps Fixes
/
MySQL
MySQL Fixes
9 troubleshooting guides — each with the error, why it happens, and copy-paste commands to fix it.
MySQL: "Server Has Gone Away" (Error 2006) — The Four Real Causes
— The server closed the connection (or it never survived).
MySQL: "Lock Wait Timeout Exceeded; Try Restarting Transaction"
— Your transaction waited innodb_lock_wait_timeout (default 50s) for a row another transaction holds.
MySQL "Access denied for user" — Grant, Host, and Password Traps
— Access denied means MySQL matched you to a user@host account and rejected the credentials — or no such account exists for your host.
MySQL "Error 1040: Too many connections"
— max_connections (often 151 by default!) is exhausted.
MySQL "InnoDB: Unable to lock ./ibdata1" — A Second Server Is Running
— Only one mysqld can own the data files.
MySQL "Can't Connect to Local Server Through Socket" — Where the Socket Went
— The client looked for a unix socket file that isn't there — mysqld is down, or it uses a different socket path than the client expects.
MySQL "Unknown Database" — Names, Grants, and Case Sensitivity
— The server doesn't know the database you named: it doesn't exist, or the lowercase/UTF8 quirks of identifiers bit you.
MySQL "Deadlock Found When Trying to Get Lock" — Reading thevictim Trace
— Two transactions each hold locks the other needs; InnoDB kills one (the victim).
MySQL "Duplicate Entry for Key PRIMARY" (Error 1062)
— A unique key collided.