When From the above figure, you can see that MySQL uses character sets in six places: client, connection, database, results, server, and system. Among them, those related to the server side: database, server, system (can never be modified, it is utf-8); those related to the client side: connection, client, results.
After understanding the above information, let's analyze the cause of the garbled characters. The problem lies in the current CMD client window, because the current CMD client input uses GBK encoding, and the database encoding format is UTF-8. The inconsistent encoding leads to garbled characters. The current encoding format of the CMD client cannot be modified, so the only way is to modify the encoding set of connection, client, and results to inform the server that the currently inserted data uses GBK encoding. Although the server's database uses UTF-8 encoding, it can recognize the GBK encoded data notified to the server and automatically convert it to UTF-8 for storage. You can use the following statement to quickly set the encoding set related to the client:
After the settings are completed, the garbled problem of data inserted or displayed on the client can be solved, but we will soon find that this form of setting is only valid in the current window. When the window is closed and the CMD client is reopened, the garbled problem will appear again; so, how to make a once-and-for-all setting? There is a my.ini configuration file in the MySQL installation directory. By modifying this configuration file, the garbled character problem can be solved once and for all. In this configuration file, [mysql] is related to the client configuration and [mysqld] is related to the server configuration. The default configuration is as follows:
At this time, you only need to change the default encoding default-character-set=utf8 to default-character-set=gbk and restart the MySQL service. Summarize The above is the Chinese garbled characters problem of MySQL database introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor 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 the problem of being unable to access the Internet after Ubuntu restarts in VMWare
>>: Mini Program implements custom multi-level single-select and multiple-select
Table of contents Compare the empty string '&...
⑴ Content determines form. First enrich the conten...
Table of contents 1. Introduction 2. Prototype ch...
Table of contents Preface Centering inline elemen...
MySQL is a relational database management system ...
I used the label tag when I was doing something re...
In the project (nodejs), multiple data need to be...
Sometimes you may need to modify or add exposed p...
When receiving this requirement, Baidu found many...
Get the current date + time (date + time) functio...
1. Basic grammar Copy code The code is as follows...
This article shares the specific code for JavaScr...
Preface Because computer numbers are floating poi...
HTML meta viewport attribute description What is ...
Table of contents Memory Pool Overview 1. nginx d...