MySQL error

Updated 11 October 2026

Short answer

"MySQL error" covers hundreds of problems, but each comes with a number and a message, and those tell you which one you have. The most common: 1045 (access denied, so the wrong username or password), 2002 (can't connect, so the server isn't running or the address is wrong), 1040 (too many connections), "server has gone away" (usually a timeout), and 1064 (a syntax error in a query, so a code bug).

What's the problem

Your site or app shows a MySQL error message, or a generic error page while the logs show ERROR 1045, ERROR 2002, SQLSTATE[HY000] or similar.

Why it happens

  • Access denied (1045): wrong credentials, or the user isn't allowed to connect from your app's host.
  • Can't connect (2002): MySQL isn't running, the host or port is wrong, or a firewall blocks it.
  • Too many connections (1040): all connection slots are in use.
  • Server has gone away: the server closed an idle or long-running connection.
  • Syntax error (1064): a broken query in the code, often from a recent change.
  • Table doesn't exist (1146): a missed migration, or the wrong database selected.
  • Disk full: MySQL can't write.

How to fix it

  1. Find the error number in the message or your app's logs.
  2. For connection errors, see database connection error.
  3. For 1040, see too many connections.
  4. For "gone away" or timeouts, see database timeout.
  5. For 1064 or 1146, check recent code changes and whether all database migrations ran on the live server.
  6. Read the MySQL error log on the database server for anything the app didn't show.

What Preventionlabs checks

One click runs the full report on your domain. For this problem it shows whether your site loads, how fast, and where its redirects go; uptime checked every 5 minutes, with an email when the site goes down and when it is back. With Cloudflare connected, it also shows which pages returned server errors (5xx) to visitors, and when; recent deploys and account changes, with their times. It can't connect to your database, so the database error itself is in your host's or database provider's logs.

Run your free report

Your first report is free, no card needed. Then A$50 a month, up to 10 domains. Read-only: it never changes anything.

Sources

  1. MySQL: Can't connect to [local] MySQL serverofficial docsThe error (2002) Can't connect to ... normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server.
  2. MySQL: Too many connectionsofficial docsThe permitted number of connections is controlled by the max_connections system variable.
  3. MySQL: MySQL server has gone awayofficial docsThe most common reason for the MySQL server has gone away error is that the server timed out and closed the connection.
  4. MySQL: Server Error Message Referenceofficial docsError number: 1045 ; Symbol: ER_ACCESS_DENIED_ERROR ; SQLSTATE: 28000
  5. MySQL: Server Error Message Referenceofficial docsError number: 1040 ; Symbol: ER_CON_COUNT_ERROR ; SQLSTATE: 08004 Message: Too many connections
  6. MySQL: Server Error Message Referenceofficial docsError number: 1064 ; Symbol: ER_PARSE_ERROR
  7. MySQL: Server Error Message Referenceofficial docsError number: 1146 ; Symbol: ER_NO_SUCH_TABLE ; SQLSTATE: 42S02
← All of Database