Skip to content

Common MySQL errors and how to fix them

“User already has more than ‘max_user_connections’ active connections”

Section titled ““User already has more than ‘max_user_connections’ active connections””

Each database user can have 20 connections open at the same time on shared hosting. This error means your site tried to open more, usually because:

  • traffic spiked, or bots are crawling the site heavily
  • slow queries keep connections open longer than they should
  • a plugin or script opens connections and doesn’t close them (for example, persistent connections)

To fix it:

  1. Turn on caching. With WordPress, use LiteSpeed Cache: cached pages don’t touch the database at all.
  2. Block bad bots and limit login attempts. See WordPress security.
  3. Find slow queries. In WordPress, Query Monitor shows which plugins run slow or many queries.
  4. Avoid persistent connections. In PHP, don’t use mysqli_pconnect or PDO::ATTR_PERSISTENT.
  5. Use separate database users for separate sites, so one busy site doesn’t use up another’s connections.

The connections close on their own, so the error usually clears within a few minutes. If it keeps happening, your site may have outgrown shared hosting. A Managed VPS lets you set your own limits.

“has exceeded the ‘max_connections_per_hour’ resource” (or max_questions / max_updates)

Section titled ““has exceeded the ‘max_connections_per_hour’ resource” (or max_questions / max_updates)”

These limits cap how many connections or queries a user can make in an hour. They aren’t normally set on Ruachost shared hosting. If you see this error, it’s usually because an app has a very high, unusual level of database activity, often caused by a bot attack, a loop in a script, or a misbehaving plugin.

Fix the cause as above, then open a support ticket if the error doesn’t clear within the hour.

“MySQL server has gone away” (error 2006)

Section titled ““MySQL server has gone away” (error 2006)”

The connection to the database closed before the query finished. Common causes:

  • A very large import or query. A single query or row is bigger than the 256 MB packet limit. Split large imports into smaller files. See Importing a large database.
  • The connection sat idle too long. Idle connections close after 8 hours. Long-running scripts and workers should reconnect when needed.
  • A script ran too long. Break long jobs into smaller batches, or run them from a cron job.

The username, password or host is wrong, or the user hasn’t been added to the database. See Fixing “Error establishing a database connection”.

Connecting from outside your hosting account? You also need to allow your IP address. See Configuring remote MySQL access.

Error 1064: “You have an error in your SQL syntax”

Section titled “Error 1064: “You have an error in your SQL syntax””

The SQL query itself is wrong: a typo, a missing quote, or a reserved word used as a name. See Understanding MySQL error 1064.

Error 1044 or 1227: “Access denied; you need the SUPER privilege”

Section titled “Error 1044 or 1227: “Access denied; you need the SUPER privilege””

This usually happens when importing a database exported from another server. It contains DEFINER statements or settings that need administrator rights. See Troubleshooting MySQL definer issues.

“Table is marked as crashed and should be repaired”

Section titled ““Table is marked as crashed and should be repaired””

Repair the table. See Optimizing and repairing MySQL databases using phpMyAdmin.