I am currently seeing a collation error with our database when search is used with certain characters Here’s an example:
WordPress database error Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8mb4_unicode_520_ci,COERCIBLE) for operation 'like' for query SELECT DISTINCT wp_posts.*
FROM wp_posts
WHERE 1=1 AND (
wp_posts.ID NOT IN (
SELECT object_id
FROM wp_term_relationships
WHERE term_taxonomy_id IN (173)
)
AND
wp_posts.ID NOT IN (
SELECT object_id
FROM wp_term_relationships
WHERE term_taxonomy_id IN (9037)
)
) AND ( ((wp_posts.post_title LIKE '%SOCとは%'))) AND (wp_posts.post_password = '') AND wp_posts.post_type = 'product' AND ((wp_posts.post_status = 'publish'))
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC
made by require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, do_action_ref_array('pre_get_posts'), WP_Hook->do_action, WP_Hook->apply_filters, DgoraWcas\Engines\WordPressNative\Search->overwriteSearchPage, DgoraWcas\Engines\WordPressNative\Search->getSearchResults, get_posts, WP_Query->query, WP_Query->get_posts
Here’s the full error:
WordPress database error: [COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1']
DELETE b
FROM wp_trp_gettext_fr_fr AS a
, wp_trp_gettext_fr_fr AS b
WHERE -- IMPORTANT: Ensures one version remains a
.ID < 0 AND b
.ID < 0 AND a
.ID
< b
.ID
-- Check for all duplicates. Binary ensure case sensitive comparison AND (a
.original
COLLATE utf8mb4_bin = b
.original
OR a
.original
IS NULL AND b
.original
IS NULL) AND (a
.translated
COLLATE utf8mb4_bin = b
.translated
OR a
.translated
IS NULL AND b
.translated
IS NULL) AND (a
.status
= b
.status
OR a
.status
IS NULL AND b
.status
IS NULL)AND (a
.domain
= b
.domain
OR a
.domain
IS NULL AND b
.domain
IS NULL);
WordPress database error: [COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1']
DELETE b
FROM wp_trp_gettext_fr_fr AS a
, wp_trp_gettext_fr_fr AS b
WHERE -- IMPORTANT: Ensures one version remains a
.ID < 10000 AND b
.ID < 10000 AND a
.ID
< b
.ID
-- Check for all duplicates. Binary ensure case sensitive comparison AND (a
.original
COLLATE utf8mb4_bin = b
.original
OR a
.original
IS NULL AND b
.original
IS NULL) AND (a
.translated
COLLATE utf8mb4_bin = b
.translated
OR a
.translated
IS NULL AND b
.translated
IS NULL) AND (a
.status
= b
.status
OR a
.status
IS NULL AND b
.status
IS NULL)AND (a
.domain
= b
.domain
OR a
.domain
IS NULL AND b
.domain
IS NULL);
{"action":"trp_update_database","trp_updb_action":"remove_duplicate_gettext_rows","trp_updb_lang":"en_GB","trp_updb_batch":0,"trp_updb_nonce":"aa67654269","trp_update_completed":"no","progress_message":"
SQL Error:<\/strong> COLLATION 'utf8mb4_bin' is not valid for CHARACTER SET 'latin1'<\/p>
Removing duplicated gettext strings for language fr_FR... done.<\/br><\/br>Removing duplicated gettext strings for language en_GB..."}
]]>My question, therefore, is: Is there a way to unpack the .daf file, correct the collation, and then repackage it?
I tried downloading the SQL file after Duplicator had already unpacked it, made the necessary changes, and then uploaded it again to the exact location. The problem is that when I go through all the steps, the .daf file is unpacked again, which overwrites my changes.
Or is there any other solution? Any help with this would be greatly appreciated.
]]>I started using WordPress 1.2 for my personal blog in 2005. Today, after 18 years, my blog is powered by the latest WordPress 6.0 and it works great, except that some of the text is not shown correctly but is still readable…
Over the years, I have noticed that MySQL / MariaDB tables have been created with different charsets and collations. This is what I have today:
and you will all agree that this is a mess!
Ideally, I would like to convert all the database tables to the default format of modern WordPress which is ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci. Would a database dump, changing the ENGINE / CHARSET / COLLATE in the SQL file and then recreating the database will work?
I understand that the “difficult part” is converting the data to the correct format. But, as I tend to write in English and, rarely, in French, this is not a big issue in the sense that most of the text is 8-bit ASCII. In fact, I would like to try to convert the tables first without actually converting the data. Do you think this will work?
Thanks.
(PS: I am proficient with SQL, mysqldump, Linux, etc.)
]]>Turns out my DB had some tables with a collation that did not exist on the target server. basically this: https://tecadmin.net/resolved-unknown-collation-utf8mb4_0900_ai_ci/
Changing the DB table collation to utf8mb4_unicode_520_ci manually did the trick in this case.
Would be good to have WPvivid warn you if the collation is unknown. I’m no DB expert, but I guess you can retrieve a list of collations from the DB before restoring the tables.
PS: Great plugin, wouldn’t wanna use/maintain WP without it
When I look at the right side of my table list in phpMyAdmin in the new host I see mostly utf8_general_ci under collation but there are a few that use utf8mb4_unicode_ci. When I look at Databases or Operations in phpMyAdmin it appears that utf8mb4_unicode_ci is the default collation. Do I need to change the default to utf8_general_ci to match most of my existing tables?
Do wp-config.php settings take priority over the settings in phpMyAdmin? My previous host was experimenting with my websites and made changes to my wp-config.php file. They added define(‘DB_COLLATE’, ”); line and edited the define(‘DB_CHARSET’, ”); in some cases adding a language when that line was completely missing previously.
I need advice for both phpMyAdmin settings and the wp-config.php file edits.
]]>I looked at your suggested link in my previous post about collation but considering that I’m very ignorant about databases, it didn’t help me much. I have been exploring phpMyAdmin and reading about collation settings but can’t find any answers about how to set phpMyAdmin collation settings after migration.
When I look at the right side of my table list in phpMyAdmin in the new host I see mostly utf8_general_ci under collation but there are a few that use utf8mb4_unicode_ci. When I look at Databases or Operations in phpMyAdmin it appears that utf8mb4_unicode_ci is the default collation. Do I need to change the default to utf8_general_ci to match most of my existing tables?
Do wp-config.php settings take priority over the settings in phpMyAdmin?
]]>I’m experiencing this error which is similar to this link. I’ve tried the methods suggested and is not helping up till now.
PHP message: WordPress database error Illegal mix of collations (utf8mb4_unicode_ci,IMPLICIT) and (utf8mb4_unicode_520_ci,IMPLICIT) for operation '=' for query
Could you provide guidance on resolving this matter?
]]>