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:
|
<<: Example of how to create and run multiple MySQL containers in Docker
>>: Vue3.0 adaptive operation of computers with different resolutions
1. What is a two-column layout? There are two typ...
All consecutive spaces or blank lines (newlines) ...
This article shares the specific code of Javascri...
Preface If you are like me, as a hard-working Jav...
Table of contents Preface Motivation for Fragment...
After the image is built successfully, it can be ...
1. Basic structure: Copy code The code is as follo...
This article example shares the specific code of ...
1. Install the built-in Linux subsystem of win10 ...
Overview of MySQL Partitioned Tables We often enc...
The select element creates a single-select or mult...
1. Meaning of partition table A partition table d...
Set a background image for the table. You can use...
Table of contents 1. Pull the Redis image 2. Crea...
In general guestbooks, forums and other places, t...