I always knew that WordPress uses utf8_general_ci
as tables collation, but recently it keeps installing utf8mb4_unicode_520_ci
.
What I do is:
- Download WordPress from wordpress.org
- Rename
wp-config-example.php
towp-config.php
Set the defined constants as below
/** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', 'utf8_general_ci');
Set database configuration properly and create an empty database with charset and collation as above.
- Open mysite.dev where the WordPress is extracted and run the WordPress installation.
- Everything installed properly, now view my database settings AND BOOM, the tables have charset
utf8mb4
and collationutf8mb4_unicode_520_ci
. Side note : Some plugins that I install later will have tables collation utf8_general_ci ...
Running mysql --version
on my machine returns:
mysql Ver 14.14 Distrib 5.7.19, for Linux (x86_64) using EditLine wrapper
Note: If I use default DB_COLLATE
and DB_CHARSET
(omit my definitions), the tables get utf8mb4_unicode_520_ci
, looks like that is the default now.
So, how do I tell WordPress to create the tables with the proper encoding ?
Thanks in advance.
DB_CHARSET
. any opinions?