Solution to mysql emoji garbled code: 1. Check the mysql table encoding through the "show create table test ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" command; 2. Set the reading encoding to "through "set names utf8mb4;" utf8mb4" is enough.
The operating environment of this tutorial: Windows 10 system, MySQL version 5.7, Dell G3 computer.
What should I do if mysql emoji is garbled?
mysql emoji garbled code
Background
You need to export a batch of data with emoji expressions from mysql directly through mysql -f < sql.sql > result.csv method, the result is that the emoji expression is garbled, start to solve it!
Ideas
First think about several possibilities of garbled codes and check them one by one.
Storage problem
Reading problem
Encoding causes display problem
Solution
Check the mysql table encoding
show create table test ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
It is found that there is no problem with the encoding, the encoding is utf8mb4, and when viewing the data, it is found that only some emoji If there is a problem, you can determine that there is no problem with the storage.
utf8mb4 is a superset of utf8
Look at the reading part again and set the reading encoding to utf8mb4
set names utf8mb4;
Select the query again, no more Coding problem, problem solved.
Recommended learning: "MySQL Video Tutorial"
The above is the detailed content of What to do if mysql emoji is garbled. For more information, please follow other related articles on the PHP Chinese website!