I'm using WP Sync DB plugin for migrating sites between dev, stage and live. Recently i ran in this problem: while creating a new instance on my local dev, WordPress created all tables with utf8mb4_unicode_ci. This leads to problems getting the data migrated. Also live servers often don't support utf8mb4 at all.

I already set define('DB_COLLATE', 'utf8_general_ci'); but WordPress ignoredt it on creation.

Any ideas?

  • not having support for utf8mb4 is an inexcusable security problem. No production setting should have any excuse for not running with it. Your question amounts to "how can I keep my sites not being secure?" :( – Mark Kaplun Feb 6 '17 at 10:01
  • the best constructive criticism is packed in a sandwich of sarcasm. Nonetheless thanks for this important hint. I will try to get updated live systems now. – bitstarr Feb 6 '17 at 14:10

You can filter every database query with the hook query, for example like this:

add_filter( 'query', function ( $query ) {
    return str_replace( 'utf8mb4_unicode_ci', 'utf8_unicode_ci', $query );

However, I would strongly recommend not to do this. Update your databases instead. The old utf8_* collations have very annoying limitations, and you will run into plugin compatibility problems with them.

And whatever you do, don't use the general variations. They cannot sort properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.