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
This article uses examples to describe the common...
1. Introduction to Varnish Varnish is a high-perf...
MySQL multi-condition query with AND keyword. In ...
1. Font properties color, specifies the color of ...
Table of contents 1. What is front-end state mana...
The database enables slow query logs Modify the c...
Robots.txt is a plain text file in which website ...
From today on, I will regularly organize some smal...
K8s k8s is a cluster. There are multiple Namespac...
Generate SSL Key and CSR file using OpenSSL To co...
Background of the accident: A few days ago, due t...
Table of contents 1. Detailed syntax of entires()...
Effect html <body> <div class="cont...
1. Implementation ideas The purpose of interface ...
Table of contents Short Introduction 1. Check the...