A Chinese garbled solution occurs when you operate mysql Databases in CMD.
Baidu .. It is said that the chcp command is used to change the cmd character encoding to 65001 (utf8 character encoding). After that, Chinese characters cannot be entered, and the query results are still garbled.
In fact, you only need to ensure that the cmd client and MySQL are both encoded in the same way.
However, the reality is that the default value of cmd is gbk (the cmd attribute can be seen below the Chinese operating system is gbk encoding), while mySQL is generally utf8 (which is also mine), which has been a misunderstanding, it does not work if you want to change the character encoding of cmd. Users mentioned about client encoding in mysql. Just tell the mysql server in cmd about the encoding of the client and the desired result set.
Procedure:
1. win + r go to cmd and switch to the bin folder in the mysql installation directory (or open my computer to find the bin folder and Enter cmd in the address bar above );
2. Enter mysql-uroot-p and enter the password as prompted to be included in the database;
3. Set the encoding;
Enter set character_set_client = gbk; tell me the text encoding on the client side
Enter set character_set_results = gbk to tell mysql to return the result set encoding. In the experiment, we found that as long as the client is gbk encoded, we only need to set this to solve the Garbled text problem.
Another useful command can achieve the effects of the above two commands at the same time:
Set charset gbk; // The effect is the same as that of the preceding two.
Success! Try inserting Chinese fields!
PS: Let's look at a simple method. Let's get it done with two lines of code!
Mysql displays Chinese garbled characters in cmd
The default cmd encoding is gbk;
Modify the character_set_results encoding of mysql to gbk;
set character_set_results = gbk;
Summary
The above is a small Editor to introduce the Chinese garbled solution for operating mysql Databases in CMD. I hope it will help you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!