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
Scenario Yesterday the system automatically backe...
1. The ENV instruction in the Dockerfile is used ...
Table of contents Preface Problem Description Cau...
Friends always ask me how to hide Linux processes...
Nginx is developed in C language and is recommend...
Preface: The importance of database backup is sel...
MySQL is a multi-user managed database that can a...
Method 1: To use respin, follow these steps: sudo...
What is a mata tag The <meta> element provi...
Linux is currently the most widely used server op...
1. Mirror images disappear in 50 and 93 [root@h50...
Through permission-based email marketing, not onl...
Installation path: /application/mysql-5.5.56 1. P...
Docker Compose Introduction to Compose Compose is...
Table of contents MySQL multi-version concurrency...