Solve the problem of garbled Chinese characters in Mysql5.7

Solve the problem of garbled Chinese characters in Mysql5.7

When using MySQL 5.7, you will find that garbled characters will appear after writing Chinese characters into the database through the web terminal, but Chinese characters will be displayed normally after directly operating SQL statements to insert data in the database. How to solve this problem? The data encoding process and principles of MySQL will not be explained here. If you are interested, you can search on Baidu.

Let's solve it directly using the following operations:

1. Open the MySQL console and enter the command show variables like 'character%';

The display is as follows:

 +--------------------------+-------------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | C:\MySQL\MySQL Server 5.0\share\charsets\ |
+--------------------------+-------------------------------------------+

2. Modify the my.ini file

 [client]

  default-character-set=utf8

  [mysqld]
  default-storage-engine=INNODB
  character-set-server=utf8
  collation-server=utf8_general_ci

3. After restarting, use the command in the first step to view it as follows:

  +--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

Also, the default character set for character_set_database and character_set_server is still latin1.

4. Enter the command: set names utf8;

After restarting, use the first step command to view:

+--------------------------+------------------------------------------------+
| Variable_name | Value |
+--------------------------+------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | C:\wamp64\bin\mysql\mysql5.7.9\share\charsets\ |
+--------------------------+------------------------------------------------+

Except character_set_filesystem which is binary, all others are utf8.

In this way, if you set the encoding to utf8 on the web side, you can enter the database normally.

The above is the editor's introduction to solving the problem of Chinese garbled characters in Mysql5.7. I hope it will be helpful to everyone. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Solution to MySQL Chinese garbled characters problem
  • Summary of solutions to Chinese garbled characters in MySQL database
  • Summary of solutions to the problem of Chinese garbled characters in Mysql
  • Solution to the Chinese garbled code problem in Mac Mysql database
  • Mysql completely solves the problem of Chinese garbled characters (Illegal mix of collations for operation)
  • MySql installation steps and graphic tutorials and solutions for Chinese garbled characters
  • Solution to garbled characters when using UTF-8 Chinese encoding in MYSQL database
  • The best solution to the Mysql Chinese garbled problem
  • How to solve the Chinese garbled problem in mysql5
  • Differences among MySQL character sets GBK, GB2312, and UTF8 to solve MYSQL Chinese garbled characters
  • A collection of solutions to MySQL Chinese garbled characters
  • Summarize the causes and solutions of MySQL Chinese garbled characters, phpmyadmin garbled characters, and php garbled characters
  • Solution to MySQL Chinese garbled characters problem
  • How to completely solve the problem of Chinese garbled characters in MySQL

<<:  Example of how to create and run multiple MySQL containers in Docker

>>:  Vue3.0 adaptive operation of computers with different resolutions

Recommend

Detailed explanation of the specific use of the ENV instruction in Dockerfile

1. The ENV instruction in the Dockerfile is used ...

Causes and solutions for MySQL data loss

Table of contents Preface Problem Description Cau...

One line of code teaches you how to hide Linux processes

Friends always ask me how to hide Linux processes...

How to install nginx under Linux

Nginx is developed in C language and is recommend...

How to write a MySQL backup script

Preface: The importance of database backup is sel...

Detailed explanation of mysql.user user table in Mysql

MySQL is a multi-user managed database that can a...

Summary of Ubuntu backup methods (four types)

Method 1: To use respin, follow these steps: sudo...

A collection of common uses of HTML meta tags

What is a mata tag The <meta> element provi...

Solve the problem of docker images disappearing

1. Mirror images disappear in 50 and 93 [root@h50...

Suggestions on creating business HTML emails

Through permission-based email marketing, not onl...

How does MySQL achieve multi-version concurrency?

Table of contents MySQL multi-version concurrency...