What to do if mysql emoji is garbled

藏色散人
Release: 2023-02-16 10:01:05
Original
1244 people have browsed it

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 < 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
Copy after login

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;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!