I'm working with an old WordPress database. In the backend, some posts contain characters like:
ü
But they display on the front end as:
ü
Changing define('DB_CHARSET', 'utf8');
in wp-config.php solves this particular issue, however for future compatibility (see: https://make.wordpress.org/core/2015/04/02/the-utf8mb4-upgrade/), I believe it's a bad idea to leave the database as is and would like to convert it. Entering a ü
directly into the PHP template works without changing anything. So this is clearly a mySQL encoding issue.
I've taken the following steps so far:
- Run the following commands from PHPMyAdmin:
ALTER DATABASE MyDb CHARACTER SET utf8;
and
ALTER TABLE wp_posts CHARACTER SET utf8;
and
UPDATE wp_posts SET post_content = convert(cast(convert(post_content using latin1) as binary) using utf8)
(taken from here: MySQL - Convert latin1 characters on a UTF8 table into UTF8)
I've also used this tool: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ to convert all tables to utf-8 mb4 encoding.
alter table wp_posts change post_content post_content LONGTEXT CHARACTER SET latin1;
alter table wp_posts change post_content post_content LONGBLOB;
alter table wp_posts change post_content post_content LONGTEXT CHARACTER SET utf8;
I've also tried this approach: http://alexking.org/blog/2008/03/06/mysql-latin1-utf8-conversion
Completely emptied wp_posts and tried entering a new post.
With all these approaches, when creating a new post and entering an ü
character, it still shows up as ü
.
This thread here also clearly describes the issues I'm having: https://wordpress.org/support/topic/trouble-converting-database-containing-special-characters-to-utf-8
Any recommendations or insights from here are much appreciated as I'm completely stuck!
Thanks