Skip to content
Development and deployment2 min read

What is utf8mb4 and why does it matter for Arabic?

Short answer

utf8mb4 is the complete UTF-8 character set in MySQL and MariaDB, using up to 4 bytes per character. It is the right choice for any Arabic site because it stores Arabic, emoji and rare symbols without turning them into question marks or garbled text.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. utf8 vs utf8mb4
  2. Character set vs collation
  3. Example: converting a database to utf8mb4
  4. Common problems
  5. On ArabyHost

If Arabic on your site appears as ???? or as strings like ال, the cause is almost always an encoding mismatch between the database and the application. Understanding utf8mb4 prevents most of these problems before they start.

utf8 vs utf8mb4

UTF-8 uses 1 to 4 bytes per character. MySQL, however, long ago defined a character set called utf8 that only accepts 3 bytes; its precise name today is utf8mb3. utf8mb4 is the real, complete UTF-8.

Character Bytes utf8 (utf8mb3) utf8mb4
A 1 works works
ع 2 works works
€ 3 works works
😀 4 fails works

Arabic letters take 2 bytes, so they fit in both. Trouble starts with the first emoji a visitor types into a comment or order, which triggers Incorrect string value or silently truncates the text.

Character set vs collation

The character set decides which characters are allowed; the collation decides how they are compared and sorted:

  • utf8mb4_unicode_ci: a safe choice for most sites, supported by both MySQL and MariaDB.
  • utf8mb4_0900_ai_ci: the MySQL 8 default. MariaDB versions may not support it, so importing a dump fails with Unknown collation. Replace it with utf8mb4_unicode_ci in the SQL file before importing.

Example: converting a database to utf8mb4

ALTER DATABASE mydb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE posts CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Then make sure the connection itself uses utf8mb4, or the problem stays:

  • PHP (PDO): mysql:host=localhost;dbname=mydb;charset=utf8mb4
  • Laravel: 'charset' => 'utf8mb4' in config/database.php
  • WordPress: define( 'DB_CHARSET', 'utf8mb4' ); in wp-config.php

Take a backup first: converting data that was already stored with the wrong encoding can damage it permanently.

Common problems

  • Strings like ال: the data is UTF-8 but is being read as latin1. Fix the connection charset before touching the data.
  • Question marks ????: the characters were lost on save because the column couldn’t hold them; they can’t be recovered from that table.
  • Specified key was too long: older versions have a smaller index limit and utf8mb4 needs more bytes per character. In Laravel, Schema::defaultStringLength(191) works around it.

On ArabyHost

MySQL/MariaDB databases are created in cPanel, which opens with one click from the Araby Panel. You can check and change each table’s collation in phpMyAdmin under the Operations tab. If an encoding error shows up on your site, the Araby AI assistant in the panel reads the error log and explains the cause and the fix. See also the MySQL database guide.

FAQ

Do I need utf8mb4 if my site is Arabic only, with no emoji?

Yes. Arabic letters do work in the old utf8, but visitors type emoji into comments and order notes, and then the save fails or the text gets cut. utf8mb4 removes that problem from the start.

What's the difference between utf8mb4_unicode_ci and utf8mb4_general_ci?

Both accept the same characters; they differ in comparison and sorting rules. utf8mb4_unicode_ci follows the Unicode standard more closely, while utf8mb4_general_ci is simpler and older. For new projects pick utf8mb4_unicode_ci or a newer collation your server supports.

Why does my Arabic text show up as العربية?

The text was saved as UTF-8 and then read back as latin1, usually because the database connection didn't set charset=utf8mb4. The fix is one consistent encoding across the table, the connection and the page.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.