Every MySQL error message has three parts: a number (1062), a five-character SQLSTATE in brackets (23000), and text that usually names the exact table, column or value at fault. Read the text slowly before searching online; most of the time it already tells you the fix. Each error message shown below was reproduced on MySQL 8.0 and copied as it appeared. They are grouped by when you hit it.
Errors when connecting
ERROR 2003: Can't connect to MySQL server
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1:3398' (10061)
Nothing answered on that host and port. Numbers in the 2000s come from the client: the server never saw your request. On Windows, 10061 means "connection refused". Check that:
- the service is running (on Windows:
services.msc, look for MySQL80 or similar; on Linux:systemctl status mysql); - you are using the right port (3306 is the default, but installers allow others);
- for a remote server,
bind-addressis not limiting MySQL to 127.0.0.1, and a firewall allows the port.
Installation-specific causes are covered in installing MySQL on Windows.
ERROR 1045: Access denied
ERROR 1045 (28000): Access denied for user 'app'@'localhost' (using password: YES)
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
The server was reached and refused the login. "using password: NO" means you forgot -p. Otherwise, the password is wrong, or no account matches the user and host combination: 'app'@'localhost' and 'app'@'%' are different accounts. If you are locked out of root, follow resetting the MySQL root password.
ERROR 1049: Unknown database
ERROR 1049 (42000): Unknown database 'shopdb'
Run SHOW DATABASES;. On Linux servers, database and table names are case-sensitive by default, so ShopDB and shopdb are different names.
Errors in the query itself
ERROR 1064: SQL syntax error
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'name' at line 1
That came from ... ORDER name;, which is missing BY. The quoted fragment after "near" is where the parser gave up, so the real mistake is usually just before it. Common causes include a missing comma between columns, a reserved word used as a name (order, group, rank), mismatched quotes, and a trailing comma before FROM or ).
ERROR 1146 and 1054: table or column does not exist
ERROR 1146 (42S02): Table 'er.customer' doesn't exist
ERROR 1054 (42S22): Unknown column 'email' in 'field list'
The message names the database (er), so you can see whether you are in the wrong database or misspelled the name (customer vs customers). For columns, check with DESCRIBE customers;. "in 'where clause'" or "in 'order clause'" tells you which part of the query to look at.
ERROR 1140 / 1055: only_full_group_by
ERROR 1140 (42000): In aggregated query without GROUP BY, expression #1 of SELECT list contains
nonaggregated column 'er.customers.name'; this is incompatible with sql_mode=only_full_group_by
From SELECT name, COUNT(*) FROM customers;. You asked for one total, plus a name with no rule for which name. Add GROUP BY name, or remove the column. Error 1055 is the same rule when a GROUP BY exists; it is explained in the GROUP BY guide.
Errors when inserting or updating data
These come from this table:
CREATE TABLE customers (id INT PRIMARY KEY, name VARCHAR(10) NOT NULL, phone VARCHAR(10), joined DATE);
CREATE TABLE orders (id INT PRIMARY KEY, customer_id INT,
FOREIGN KEY (customer_id) REFERENCES customers(id));
INSERT INTO customers VALUES (1,'Tanvi','9800000001','2026-01-05');
| Statement | Error | Fix |
|---|---|---|
INSERT ... VALUES (1,'Rehan',...) | 1062 Duplicate entry '1' for key 'customers.PRIMARY' | Use a new key, let AUTO_INCREMENT assign it, or use INSERT ... ON DUPLICATE KEY UPDATE if an update is intended |
name = 'Mohammed Irfan' | 1406 Data too long for column 'name' at row 1 | Widen the column (ALTER TABLE ... MODIFY name VARCHAR(60)); do not truncate people's names |
joined = '11-02-2026' | 1292 Incorrect date value: '11-02-2026' for column 'joined' | Send '2026-02-11', or convert with STR_TO_DATE('11-02-2026','%d-%m-%Y') |
INSERT (id, phone) VALUES (4, ...) | 1364 Field 'name' doesn't have a default value | Supply the NOT NULL column, or give it a DEFAULT |
id = 'five' | 1366 Incorrect integer value: 'five' for column 'id' | Clean the source data. In CSV imports this often means a header row or a misplaced column |
INSERT INTO orders VALUES (10, 7) | 1452 Cannot add or update a child row: a foreign key constraint fails | Insert the parent (customer 7) first, or fix the ID |
DROP TABLE customers | 3730 Cannot drop table 'customers' referenced by a foreign key constraint | Drop the child table or its foreign key first |
All of these are errors, not warnings, because MySQL 8.0 runs in strict mode by default. Older setups without strict mode silently cut values and stored zero dates instead. If an import "worked" but the data looks wrong, run SHOW WARNINGS; right after it. The rules behind 1062, 1452 and friends are explained in MySQL constraints explained.
Errors caused by other sessions
ERROR 1205: Lock wait timeout exceeded
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction
Reproduced by leaving one session in an open transaction that had updated a row, then updating the same row from a second session. InnoDB waits innodb_lock_wait_timeout seconds (50 by default) and then gives up on the statement. To find the session that holds the lock:
SELECT * FROM sys.innodb_lock_waits\G
The usual root cause is a transaction left open: an app that forgot to commit, or a Workbench tab with autocommit turned off. Keep transactions short, and commit or roll back promptly. See transactions and ACID.
ERROR 1213: Deadlock found
Two transactions each hold a lock the other needs. InnoDB detects this at once and rolls one of them back. It is not a server fault. Retry the transaction in the application, and reduce deadlocks by touching rows in the same order everywhere. SHOW ENGINE INNODB STATUS\G shows the most recent deadlock.
A routine for any error
- Read the number. 1xxx and 3xxx come from the server; 2xxx come from the client or connection.
- Read the names in quotes: database, table, column, value, constraint.
- Run the failing statement alone, outside the application, to rule out the app's own code.
- Check
SHOW WARNINGS;and the server error log for connection and startup problems. - Look up the number in the MySQL "Server Error Message Reference" for your version.