WordPress

Resolving WordPress MySQL Charset Issues with MySQL 8.0 in cPanel Hosting

By the Domain India teamPublished 8 min read
Knowledge base article
Contents (9 sections)

Character set problems in WordPress show up as garbled text such as é or ’, question marks where Hindi or emoji should be, or an import that stops with Unknown collation: 'utf8mb4_0900_ai_ci'. The fix is the same in every case: store and read everything as utf8mb4. This guide shows how to check your database, convert old tables safely and import a MySQL 8.0 dump on a MariaDB server.

Key takeaways

Set DB_CHARSET to utf8mb4 in wp-config.php, find tables still using latin1 or the old 3-byte utf8, and convert them with ALTER TABLE … CONVERT TO CHARACTER SET utf8mb4 after a full backup. If an import from a MySQL 8.0 server fails with utf8mb4_0900_ai_ci, replace that collation with utf8mb4_unicode_520_ci in the dump. A "missing MySQL extension" error is a different problem: it comes from the PHP version or a very old WordPress, not from the character set.

1. Character sets in two minutes

A character set decides how text is stored as bytes; a collation decides how text is compared and sorted.

Character setWhat it storesUse it?
latin1Western European letters onlyNo, for any new data
utf8 or utf8mb3Most Unicode, but only up to 3 bytes per character, so no emojiNo; convert away from it
utf8mb4All of Unicode, including emoji and every Indian scriptYes, everywhere

WordPress has used utf8mb4 by default since version 4.2 and converts its own tables to it during a database upgrade when the server supports it. Problems come from sites that were built before that, tables created by plugins, and databases moved between servers.

2. Which server are you on?

The title of this article mentions MySQL 8.0, but a database server can be MySQL or MariaDB. Our cPanel and DirectAdmin shared servers run MariaDB. To see the exact version, open phpMyAdmin and read Server version in the Database server panel on the right. It matters for one error in particular: MySQL 8.0 names its default collation utf8mb4_0900_ai_ci, and MariaDB does not recognise that name.

3. Symptoms and what they mean

SymptomLikely causeSection
é, ’ or similar in postsText stored in one character set and read as another5 and 6
Emoji or some characters become ????Table or column is latin1 or utf8mb35
Unknown collation utf8mb4_0900_ai_ci on importDump made on MySQL 8.0, imported into MariaDB7
Your PHP installation appears to be missing the MySQL extensionNot a charset problem; see section 88
Error establishing a database connectionWrong credentials, host or database name; not a charset problem8

4. Back up first

Every step below rewrites tables. Before you start:

5. Check and convert your tables

  1. Set the connection character set.
    Edit wp-config.php with File Manager and make sure these two lines read: define( 'DB_CHARSET', 'utf8mb4' ); and define( 'DB_COLLATE', '' );. An empty DB_COLLATE lets WordPress pick the best utf8mb4 collation the server supports.
  2. Find tables that are not utf8mb4.
    In phpMyAdmin, select your WordPress database, open the SQL tab and run the first query below. Any table listed needs converting.
  3. Generate the conversion statements.
    Run the second query below. It writes one ALTER TABLE line per table that needs it.
  4. Run the statements.
    Copy the results back into the SQL tab and run them. Large tables can take a while; if one times out, run it again on its own.
  5. Change the database default.
    Run the ALTER DATABASE line below, so tables that plugins create later also use utf8mb4.
  6. Check the site.
    Open posts and pages with accented text, Indian scripts or emoji. If text now looks garbled, restore your backup and read section 6.

Query for step 2:

sql
SELECT TABLE_NAME, TABLE_COLLATION
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = DATABASE()
  AND TABLE_COLLATION NOT LIKE 'utf8mb4%';

Query for step 3:

sql
SELECT CONCAT('ALTER TABLE `', TABLE_NAME,
  '` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;')
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = DATABASE()
  AND TABLE_COLLATION NOT LIKE 'utf8mb4%';

Statement for step 5 (replace the name with your database):

sql
ALTER DATABASE `cpaneluser_wp` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;

If jailed SSH is enabled on your account, WP-CLI can do the export for you with wp db export before you start. SSH is off by default; ask support to turn it on.

6. When conversion makes text worse

CONVERT TO CHARACTER SET assumes the bytes in a table really are in the table's declared character set. On old sites, UTF-8 text was often saved into latin1 tables. The page looked right, because it was written and read the same wrong way, but converting such a table encodes the text twice and turns it into é-style garbage.

If that happens, restore your backup and don't run the conversion again. Fixing double-encoded data means converting each text column to a binary type and then to utf8mb4, column by column, and it is easy to get wrong. Test it on a copy of the database, or ask a developer. Tools such as the "Better Search Replace" plugin cannot fix the encoding itself.

7. Importing a MySQL 8.0 dump into MariaDB

A dump exported from MySQL 8.0 often contains utf8mb4_0900_ai_ci, which MariaDB rejects with Unknown collation. Fix the file before you import it:

  1. Open the dump in a plain-text editor
    that handles large files, such as VS Code or Notepad++.
  2. Replace every utf8mb4_0900_ai_ci
    with utf8mb4_unicode_520_ci.
  3. Save and import again
    in phpMyAdmin. On cPanel, phpMyAdmin accepts files up to 50 MB; compress the dump as .sql.gz if it is larger.

For other import errors, see Database troubleshooting.

8. Errors that are not about character sets

"Your PHP installation appears to be missing the MySQL extension which is required by WordPress." WordPress needs PHP's mysqli extension. The error appears when a very old WordPress, which used the mysql_* functions removed in PHP 7, runs on a modern PHP, or when the selected PHP version doesn't load mysqli. Update WordPress, and choose a current PHP version in your control panel. Don't downgrade PHP to make it go away: old PHP versions no longer receive security fixes.

"Error establishing a database connection." WordPress can't log in to the database. Check the database name, user, password and host in wp-config.php. See Troubleshooting "Error establishing a database connection".

9. Where Domain India fits

Domain India shared hosting includes MariaDB databases managed with phpMyAdmin, a choice of PHP versions in the control panel, and weekly JetBackup 5 backups on cPanel and DirectAdmin. For a new WordPress site, see WordPress hosting, or start with a cPanel plan:

cPanel Starter
₹125/mo + GST
  • 25 GB NVMe SSD Storage
  • 50 GB Monthly Bandwidth
  • 1 Website
  • 10 Email Accounts
See plan details

The card shows the live Domain India price, excluding 18% GST.

Which character set should a WordPress database use?

utf8mb4, for the database, every table and the connection. Set DB_CHARSET to utf8mb4 in wp-config.php. Unlike latin1, it stores Indian scripts, and unlike the old 3-byte utf8, it also stores emoji.

How do I fix "Unknown collation: utf8mb4_0900_ai_ci" when importing?

The dump was made on MySQL 8.0 and the target server runs MariaDB, which does not know that collation. Replace utf8mb4_0900_ai_ci with utf8mb4_unicode_520_ci in the dump file and import it again.

Does a character set problem cause the "missing MySQL extension" error?

No. That error means PHP cannot find the mysqli extension WordPress needs, usually because a very old WordPress is running on modern PHP. Update WordPress and choose a current PHP version in your control panel.

Is it safe to convert WordPress tables to utf8mb4?

It is safe for tables whose data really is in their declared character set, which is most of them. Always export a backup first. If text looks garbled after converting, the data was double-encoded; restore the backup and fix those columns separately.

Which MySQL version do Domain India shared servers use?

Our cPanel and DirectAdmin shared servers run MariaDB. The exact version is shown as Server version on the phpMyAdmin home page.

What should DB_COLLATE be in wp-config.php?

Leave it empty. WordPress then chooses the best utf8mb4 collation the database server supports.

Ready to fix your database? Take a backup, then open phpMyAdmin from your hosting services. If the conversion goes wrong or you're unsure, open a support ticket with the database name and the error you see.

Stuck on a database error?

Tell us the database name, the exact error and what you were doing, and our team will help you find the cause.

Open a support ticket

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
Fix WordPress Charset Issues: utf8mb4, MySQL 8.0, MariaDB