Troubleshooting

Conflict with Drupal's "system" table in MySQL 8 (error 1064)

Reviewed on 3 min read MySQL compatibility

MySQL 8 extended the list of reserved words: words that cannot be used, for example, as a table name in a query unless they are escaped. One of them is system, which is exactly the name of a Drupal table.

If your Drupal does not use a table prefix, with MySQL 8 you will see errors like this one, with system in the failing query:

Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds

Drupal 6 and Drupal 7 no longer receive security updates (Drupal 7 stopped receiving them in January 2025). These fixes are meant to keep the website running while you plan its move to a current version of Drupal.

Drupal 7: update to 7.76 or later

Drupal 7.76 added support for MySQL 8 and escapes reserved names itself, so the solution is to update to the latest version of the 7 branch, 7.103. Check your version in Reports > Status report.

Make a backup of the files and the database, and update following the UPGRADE.txt file included with Drupal: replace all the files except the sites folder and .htaccess if you have modified it, and then open tudominio.com/update.php.

If you cannot update, apply the fix in the next section with the Drupal 7 syntax.

Drupal 6 (or Drupal 7 without updating): rename the table and add a prefix

The idea is to rename the system table to something that is not reserved, for example tb_system, and tell Drupal that this table has the tb_ prefix.

  1. Make a backup of the database.
  2. Open phpMyAdmin from cPanel, open the system table and, in the Operations tab, rename it to tb_system.
  3. Edit the sites/default/settings.php file.

In Drupal 6, find the line:

$db_prefix = '';

This line sets a prefix for all tables, but it also accepts an array with prefixes for only some of them. Change it to:

$db_prefix = array(
    'default' => '',
    'system' => 'tb_',
);

In Drupal 7, the prefix goes inside $databases. Find the default connection and change its prefix:

$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => 'usuario_drupal',
  'username' => 'usuario_drupal',
  'password' => 'tu-contraseña',
  'host' => 'localhost',
  'prefix' => array(
    'default' => '',
    'system' => 'tb_',
  ),
);

Keep your own database, user and password details; only change the prefix part.

With this, Drupal looks for the system table as tb_system, the conflict disappears and the website works again with MySQL 8.

If it still fails

Look at the full query in the error. If the problem is no longer system but another word, look it up in the list of MySQL 8 reserved words. If it comes from a module, update it or fix it in its files, escaping the word with backticks (`word`).

You may also find useful

Something wrong or out of date? Tell us and we will review it.