Home  >  Article  >  Database  >  What to do if mysql emoji is garbled

What to do if mysql emoji is garbled

藏色散人
藏色散人Original
2023-02-16 10:01:051347browse

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.

What to do if mysql emoji is garbled

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 3b4be98fece41d5958f1e4e9fde66768 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn