Post en français ici.
TL;DR: To avoid accent issues after the MySQL 5.7 to 8.0 upgrade, check that DB_CHARSET is set in your Wordpress' wp-config.php.
----------
Brace yourself, MySQL 8.0 is coming soon on the databases delivered with your web hostings, also called "SharedSQL" (more info soon). Waiting for that, I have several topics for you, and this is the first one. It's about the Wordpress sites created before 2007 (more precisely: Wordpress sites created before Wordpress 2.2, released in 2007).
Warning, if your web site had been created with a Wordpress before 2.2, then upgraded, then you may be impacted, even if you use the last Wordpress version. Explanations and easy solution, let's go! 😃
**Technical context**
First of all, a little bit of context. I love to know where we come from. This helps to know where we're going 🙂
2001, Michael Widenius co-funded MySQL. Michael is from Finland. So he choosed the latin1 / swedish as the default character set / collation of MySQL (Finnish uses an alphabet derived from the Swedish one).
At that time, that was OK, as Michael had no idea his DBMS will be one of the most massively used in the world years later.
But it quickly became a problem, as the Swedish alphabet is not the most popular or relevant one to use all over the world. And that's a big problem, as moving from a character set / collation to another one is a real pain.
Proof: 22 years later, latin1 / swedish were still the default character set / collation in MySQL 5.7!
Since MySQL 8.0, the default character set is UTF-8 (called "utf8mb4" by MySQL).
**Wordpress default charset**
By default, Wordpress uses the character set defined on wp-config.php:
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
This parameter is UTF-8 by default, and exists since Wordpress 2.2, released 17 years ago, in 2007.
If this parameter is not set (what is the case of Wordpress created before September 2007), then Wordpress uses the database default character set.
As MySQL 8.0 changes the default character set from latin1 to utf8mb4, Wordpress that do not have this parameter (so, they're using latin1) will encounter accent issues (for instance, a "é" seen as "é"). Indeed, the data is encoded using latin1 in the database (that stays as-is), but they will be seen as UTF-8.
**Impact**
If you have:
1. A Wordpress
2. AND content on your database using latin1 (with means your database had been created with a Wordpress before 2007)
3. AND you didn't specified DB_CHARSET
Then, your website will have charset issues.
**Solution**
The solution is easy, and you can set it up right now:
* If you have a DB_CHARSET in your wp-config.php, keep it as-is, whatever its value.
* If you do not have any DB_CHARSET in your wp-config.php, then add this to your file, now:
define( 'DB_CHARSET', 'latin1' );
Mikaël
MySQL 8.0: Prepare your (really) old Wordpress
Related questions
- [RESOLU] Server unable to read htaccess file, denying access to be safe
58996
24.11.2019 19:11
- Version php 7.0 sur Ovh mais php 5.4.45 sur mon wordpress
54417
10.01.2019 11:14
- Effacer wordpress d'OVH et reinstaller
53585
08.09.2019 21:02
- Comment récupérer son mot de passe phpmyadmin ?
51903
14.11.2016 10:32
- Changer la version d'une base de donnée en mutualisé
50427
22.12.2016 11:46
- Ne supporte pas FTP sur TLS
49107
11.12.2018 18:48
- Résiliation hébergement
48819
27.07.2018 10:39
- Variable upload_max_filesize plus grande que post_max_size
44592
11.06.2017 16:01
- Résiliation hébergement+domaine
43078
11.09.2018 20:28
- Transfert hebergement et domaine .fr entre client OVH ?
41611
21.12.2016 15:10