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

N ways to achieve two-column layout with CSS

1. What is a two-column layout? There are two typ...

A brief discussion on spaces and blank lines in HTML code

All consecutive spaces or blank lines (newlines) ...

Javascript to achieve drumming effect

This article shares the specific code of Javascri...

Correct steps to install Nginx in Linux

Preface If you are like me, as a hard-working Jav...

React Fragment Introduction and Detailed Usage

Table of contents Preface Motivation for Fragment...

Implementation of pushing Docker images to Docker Hub

After the image is built successfully, it can be ...

Implementing user registration function with js

This article example shares the specific code of ...

How to start the spring-boot project using the built-in linux system in win10

1. Install the built-in Linux subsystem of win10 ...

Correct use of MySQL partition tables

Overview of MySQL Partitioned Tables We often enc...

HTML table tag tutorial (8): background image attribute BACKGROUND

Set a background image for the table. You can use...

Implementation of Redis master-slave cluster based on Docker

Table of contents 1. Pull the Redis image 2. Crea...

Some parameter descriptions of text input boxes in web design

In general guestbooks, forums and other places, t...