How to stop WordPress from using utf8mb4_unicode_ci collation

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?

Topic collation database Wordpress

Category Web


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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.