Unknown collation ‘utf8mb4_unicode_520_ci’

Getting the error unknown collation ‘utf8mb4_unicode_520_ci’ when trying to upload your SQL file into phpMyAdmin? You just need to run a quick find and replace.

How to replace utf8mb4_unicode_520_ci

In order to successfully upload your WordPress database file, you need to run the following two find and replace functions in your SQL file first.

1. Find and replace (part-1)

Find: CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

Replace: CHARSET=utf8 COLLATE=utf8_general_ci;

2. Find and replace (part-2)

Find: utf8mb4_unicode_520_ci

Replace: utf8_general_ci

3. Fixing the Table ‘table_name’ already exists error

When you come to re-upload your SQL file, you may see an error similar to Table ‘table_name’ already exists.

Note, at this point, you should make a backup by viewing the database and clicking the export button in the menu.

Once you’ve backed the current database up, you need to follow the steps below to drop the tables you’ve recently tried to import:

  1. Select all the WordPress tables inside your database (there’s a select-all button in phpMyAdmin, if necessary)
  2. Click the drop button to delete the selected tables.

Once you’ve done this, you should be able to upload without any errors.