SQL file import error: Unknown collation 'utf8mb4_unicode_ci'

更新时间:
复制 MD 格式

When you import an SQL file by using Data Management (DMS), you may receive the error Unknown collation: 'utf8mb4_unicode_ci'. This topic describes why this error occurs and how to resolve it.

Symptoms

When you import an SQL file by using Data Management (DMS), the following error is returned: Unknown collation: 'utf8mb4_unicode_ci'.

[2015-06-17 14:25:40]: Preparing database connection information...
[2015-06-17 14:25:40]: Database connection ready.
[2015-06-17 14:25:40]: Starting to parse the file...
[2015-06-17 14:25:40]: Reading file content. The file character set is automatically detected.
[2015-06-17 14:25:40]: File character set automatically detected as UTF-8.
[2015-06-17 14:25:40]: File content reading complete.
[2015-06-17 14:25:40]: File parsing complete. Time elapsed: 3ms.
[2015-06-17 14:25:40]: Importing as SQL statements. Starting to process...
[2015-06-17 14:25:40]: Parsing SQL statements in the file...
[2015-06-17 14:25:40]: SQL statements in file parsed.
[2015-06-17 14:25:40]: Estimated number of SQL statements to import: 557
[2015-06-17 14:25:40]: ==========================================
Error occurred on SQL statement:
CREATE TABLE `wp_commentmeta` (
  `meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `comment_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meta_value` longtext COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`meta_id`),
  KEY `comment_id` (`comment_id`),
  KEY `meta_key` (`meta_key`(191))
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
Error message: Unknown collation: 'utf8mb4_unicode_ci'
[2015-06-17 14:25:40]:
Number of successfully executed SQL statements: 2

Possible causes

MySQL versions 5.5.3 and later support the utf8mb4 character set. The MySQL database provided with your Web Hosting instance is version 5.1.48, which does not support this character set.

Solution

  1. The solution depends on whether you must use the utf8mb4 character set.

    • If you do not need to use the utf8mb4 character set, follow these steps:

      1. Save a backup copy of the SQL file to your local device.

      2. Open the SQL file in a text editor.

      3. Modify the parameters in the file, and then save the file.

        • Replace CHARSET = utf8mb4 with CHARSET = utf8.

        • Replace COLLATE = utf8mb4_unicode_ci with COLLATE = utf8_general_ci.

    • If you must use the utf8mb4 character set, upgrade your instance or purchase a new Web Hosting instance with a later MySQL version. For more information, see Upgrade a Web Hosting instance and Purchase a Web Hosting instance.

  2. Import the SQL file again.

    If the issue persists, submit a ticket.