nousicek
nousicek

Reputation: 27

Unknown collation 1273 error MySQL

I am migrating a wordpress site but when I try to import the database I get the following error:

1273 - Unknown collation: 'utf8mb4_unicode_520_ci'

I think that it is caused because of the different version of MySQL, is that correct? How to fix the code below? This is how every table is created.

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_520_ci DEFAULT NULL,
  `meta_value` longtext COLLATE utf8mb4_unicode_520_ci,
  PRIMARY KEY (`meta_id`),
  KEY `comment_id` (`comment_id`),
  KEY `meta_key` (`meta_key`(191))
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

Upvotes: 0

Views: 12219

Answers (2)

Babak Momeni
Babak Momeni

Reputation: 76

If you are using a Linux server, you can simply use the following command to change SQL file before import it into the database:

sudo sed -i 's/utf8mb4_unicode_520_ci/utf8mb4_unicode_ci/g' your_sql_file.sql

Do not forget to replace your_sql_file.sql with path and name of your own file.

Upvotes: 1

Ashish Odich
Ashish Odich

Reputation: 571

You can solve this by finding

ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

in your .sql file, and swapping it with

ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

Upvotes: 4

Related Questions