Error Codes Wiki

Linux MySQL Error Codes — 1045, 2002, 1205 & Common Database Errors

Errordatabase

Overview

Fix common MySQL errors including ERROR 1045 (access denied), ERROR 2002 (cannot connect), ERROR 1205 (lock wait timeout), and table corruption.

Key Details

  • ERROR 1045 (28000): Access denied for user — wrong credentials or missing grants
  • ERROR 2002 (HY000): Cannot connect to local MySQL server through socket
  • ERROR 1205 (HY000): Lock wait timeout exceeded — deadlock or long transaction
  • ERROR 1146 (42S02): Table does not exist — wrong name or dropped table
  • ERROR 2006: MySQL server has gone away — connection timeout or max_allowed_packet exceeded

Common Causes

  • 1045: wrong password, user does not exist, or missing GRANT privileges
  • 2002: MySQL service not running or socket file missing/wrong path
  • 1205: long-running transaction holding a lock, causing other queries to timeout
  • 2006: packet too large (max_allowed_packet) or connection idle too long
  • Table corruption from unexpected shutdown or disk errors

Steps

  1. 1For 1045: reset password — sudo mysql then ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpass';
  2. 2For 2002: check if MySQL is running — systemctl status mysql, start if needed
  3. 3For 1205: find blocking query — SHOW PROCESSLIST; kill the long-running transaction
  4. 4For 2006: increase max_allowed_packet in my.cnf: max_allowed_packet = 64M
  5. 5For corruption: CHECK TABLE tablename; then REPAIR TABLE tablename;

Tags

linuxmysqldatabaseerror-1045error-2002

Frequently Asked Questions

Stop MySQL, start with --skip-grant-tables, connect without password, run ALTER USER to set new password, restart normally.