Skip to content

Edoardo Vignati 👨🏻‍💻

› Always looking for awesome things

Menu
  • Studies
  • Publications
  • Skills
  • Portfolio
  • Projects
  • Career
  • Blog
  • 🇮🇹 Servizi
Menu

[Solved] MySQL not decoding emojis and special characters

Posted on 08/04/202308/04/2023 by Edoardo

If you have this problem, you should check 4 things.

Encoding of tables

Open PhpMyAdmin and check whether the database is encoded with utf8mb4_unicode_ci and also all the columns have the same encodign or not

Encoding of MySQL

If you are on Linux, go to /etc/mysql/my.cnf and add or edit the following:

[client]
default-character-set=utf8mb4

[mysql]
default-character-set=utf8mb4

[mysqld]
collation-server = utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'
character-set-server = utf8mb4

Then restart mysql:

$ sudo service mysqld restart

Encoding in connection

If you are using PHP to connect, add the encoding just after the connection in this way:

$conn = new mysqli($servername, $username, $password, $db);
$conn->query("SET NAMES 'utf8mb4'");

Encoding in frontend

If you are running on HTML try to put this meta tag

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Buy Me A Coffee


This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2025 Edoardo Vignati 👨🏻‍💻 | Powered by Minimalist Blog WordPress Theme