MySQL Error Reference

This page lists the common MySQL errors that you may encounter.

Complete error list can be found in the MySQL official documentation.

Connection Errors

  • ERROR 1040 (HY000): Too Many Connections

    ERROR 1040 (HY000): Too many connections
  • ERROR 1130 (HY000): Host is not allowed to connect

    ERROR 1130 (HY000): Host 'client-hostname' is not allowed to connect to this MySQL server
  • ERROR 2002 (HY000): Can't connect to local MySQL server through socket

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
  • ERROR 2003 (HY000): Can't connect to MySQL server on '[host]'

    ERROR 2003 (HY000): Can't connect to MySQL server on 'hostname' (110)
  • ERROR 2013 (HY000): Lost connection to MySQL server during query

    ERROR 2013 (HY000): Lost connection to MySQL server during query

Privilege Errors

  • ERROR 1041 (42000): You are not allowed to create a user with GRANT

    ERROR 1041 (42000): You are not allowed to create a user with GRANT
  • ERROR 1044 (42000): Access denied for user to database

    ERROR 1044 (42000): Access denied for user 'username'@'hostname' to database 'db_name'
  • ERROR 1045 (42000): Access denied for user 'username'@'hostname' (using password: YES)

    ERROR 1045 (42000): Access denied for user 'username'@'hostname' (using password: YES)
  • ERROR 1049 (42000): Unknown Database

    ERROR 1049 (42000): Unknown database 'db_name'
  • ERROR 1142 (42000): Command denied to user

    ERROR 1142 (42000): SELECT command denied to user 'username'@'hostname' for table 'table_name'
  • ERROR 1396 (HY000): Operation failed for user

    ERROR 1396 (HY000): Operation CREATE USER failed for 'username'@'hostname'

Data Modification Errors

  • ERROR 1062 (23000): Duplicate entry

    ERROR 1062 (23000): Duplicate entry '123' for key 'PRIMARY'
  • ERROR 1153 (08S01): Got a packet bigger than 'max_allowed_packet'

    ERROR 1153 (08S01): Got a packet bigger than 'max_allowed_packet' bytes
  • ERROR 1175 (HY000): You are using safe update mode

    ERROR 1175 (HY000): You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
  • ERROR 1213 (40001): Deadlock found when trying to get lock

    ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction

Foreign Key Errors

  • ERROR 1215 (HY000): Cannot add foreign key constraint

    ERROR 1215 (HY000): Cannot add foreign key constraint
  • ERROR 1216 (23000): Cannot add or update a child row: a foreign key constraint fails

    ERROR 1216 (23000): Cannot add or update a child row: a foreign key constraint fails
  • ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails

    ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails
  • ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails

    ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails

Edit this page on GitHub