I have a wordpress database on my local machine that I want to
transfer to a hosted phpMyAdmin on Cpanel. However when I try to import
the database into the environment, I keep getting this error
I have tried to google around and the only solution I can find is this one phpmysql error - #1273 - #1273 - Unknown collation: 'utf8mb4_general_ci' which as by now isn't much help. I have tried clearing the cookies but it still won't work. Please help! |
||
add a comment
|
I had the same issue as all of our servers run older versions of
MySQL. This can be solved by running a PHP script. Save this code to a
file and run it entering the database name, user and password and it'll
change the collation from
utf8mb4/utf8mb4_unicode_ci to utf8/utf8_general_ci
|
||||
The technique in this post worked for me
1) Click the "Export" tab for the database 2) Click the "Custom" radio button 3) Go the section titled "Format-specific options" and change the dropdown for "Database system or older MySQL server to maximize output compatibility with:" from NONE to MYSQL40. 4) Scroll to the bottom and click "GO". I'm not certain if doing this causes any data loss, however in the one time I've tried it I did not notice any. Neither did anyone who responded in the forums linked to above. |
|||||||||||||||||||||
|
The best thing to do is export your database to .sql, open it on notepad++ and go to "search and replace". Then you put "mb4" on search and nothing on replace. It will replace the utf8mb4_unicode_ci to utf8_unicode_ci. Now you go to your phpmyadmin( destination ) and set the db collation to utf8_unicode_ci. ( Operations > Collation ).
WORKS PERFECTLLY |
|||||||||
|
Seems like your host does not provide a MySQL-version which is capable to run tables with utf8mb4 collation.
The WordPress tables were changed to utf8mb4 with Version 4.2 (released on April, 23rd 2015) to support Emojis, but you need MySQL 5.5.3 to use it. 5.5.3. is from March 2010, so it should normally be widely available. Cna you check if your hoster provides that version? If not, and an upgrade is not possible, you might have to look out for another hoster to run the latest WordPress versions (and you should always do that for security reasons). |
|||||
|
Wordpress 4.2 introduced support for "utf8mb4" character encoding for security reasons,
but only MySQL 5.5.3 and greater support it. The way the installer (and
updater) handles this is that it checks your MySQL version and your
database will be upgraded to utfmb4 only if it's supported.
This sounds great in theory but the problem (as you've discovered) is when you are migrating databases from a MySQL server that supports utf8mb4 to one that doesn't. While the other way around should work, it's basically a one-way operation. As pointed out by Evster you might have success using PHPMYAdmin's "Export" feature. Use "Export Method: Custom" and for the "Database system or older MySQL server to maximize output compatibility with:" dropdown select "MYSQL 40". For a command line export using mysqldump. Have a look at the flag:
Note: If there are any 4-byte characters in the database they will be corrupted.Lastly, for anyone using the popular WP Migrate DB PRO plugin, a user in this Wordpress.org thread reports that the migration is always handled properly but I wasn't able to find anything official. The WP Migrate DB plugin translates the database from one collation to the other when it moves 4.2 sites between hosts with pre- or post-5.5.3 MySQLAt this time, there doesn't appear to be a way to opt out of the database update. So if you are using a workflow where you are migrating a site from a server or localhost with MySQL > 5.5.3 to one that uses an older MySQL version you might be out of luck. |
|||||||||
|
There is a line in wp-config.php:
If you follow Markouver's / Evster's instructions, don't forget to change this line on production server to
in order to fix broken 4-byte characters |
|||
After the long time research i have found the solution for above:
|
|||||
|
I also experienced this issue. Solution which worked for me was opening local database with Sequel Pro and update Encoding and Collation to utf8/utf8_bin for each table before importing.
|
|||
mysqldump --compatible=mysql4
– icc97 Aug 4 at 20:32db-convert.php
– Fred K Sep 4 at 15:46