Error message: Incorrect table name or identifier name ... is too long

|

Table of Contents

Problem

One or more database tables cannot be created.

Cause

In most cases, the table prefix defined in wp-config.php of $table_prefix = 'XXX'; is too long. As a result, MySQL/MariaDB limits are exceeded and the required tables cannot be created.

Solution

The table prefix must be changed and should not exceed 3 to 5 characters in length. To do this, shorten the value of $table_prefix and then rename all existing tables in the database accordingly.

In addition, some settings stored in the database still reference the old table prefix. To complete the migration, you must update these entries to use the new prefix.

In the following example, the table prefix is changed from $table_prefix = 'OLD'; to $table_prefix = 'NEW';:

UPDATE `NEW_usermeta` SET `meta_key` = 'NEW_capabilities' WHERE `meta_key` = 'OLD_capabilities';
UPDATE `NEW_usermeta` SET `meta_key` = 'NEW_user_level' WHERE `meta_key` = 'OLD_user_level';
UPDATE `NEW_usermeta` SET `meta_key` = 'NEW_autosave_draft_ids' WHERE `meta_key` = 'OLD_autosave_draft_ids';
UPDATE `NEW_options` SET `option_name` = 'NEW_user_roles' WHERE `option_name` = 'OLD_user_roles';

This procedure should only be performed by experienced users.

Was this article helpful?

Helpful
Not helpful

Couldn't find the answer you were looking for? We're happy to help.