Error Codes Wiki

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

Errordatabase

About Linux MySQL Error Codes

Fix common MySQL errors including ERROR 1045 (access denied), ERROR 2002 (cannot connect), ERROR 1205 (lock wait timeout), and table corruption. This guide covers everything you need to know about this topic, including common causes, step-by-step solutions, and answers to frequently asked questions.

Here are the key things to understand: 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. Understanding these fundamentals will help you diagnose and resolve this issue more effectively.

The most common reasons this occurs include: 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. Identifying the root cause is the first step toward finding the right solution.

To resolve this, follow these recommended steps: For 1045: reset password — sudo mysql then ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpass';. For 2002: check if MySQL is running — systemctl status mysql, start if needed. For 1205: find blocking query — SHOW PROCESSLIST; kill the long-running transaction. For 2006: increase max_allowed_packet in my.cnf: max_allowed_packet = 64M. For corruption: CHECK TABLE tablename; then REPAIR TABLE tablename;. If these steps do not resolve the issue, consider consulting additional resources or a qualified professional.

This article is part of our Linux Error Codes collection on Error Codes Wiki. We provide comprehensive, up-to-date information to help you find solutions quickly.

Quick Answer

How do I reset the MySQL root password?

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

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

More in Database

Frequently Asked Questions

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