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
In the past few days, the website has been access...
1. Introduction First of all, we need to answer a...
Preface Recently, I encountered a requirement at ...
Table of contents Debounce Throttle Summarize Deb...
Note 1: The entire background in the above pictur...
<button> tag <br />Definition and usag...
This article explains the difference between arro...
1. Preparation before installation Check the data...
This article shares the specific code of js to im...
background I have a project service that uses AWS...
Nowadays, application development is basically se...
<br />Semanticization cannot be explained in...
An application of CSS animation, with the same co...
Preface In daily work, we sometimes run slow quer...
Step 1: Add Ubuntu source Switch to root su root ...