How to query garbled characters using the MySQL command line Client
Today, when you use the MySQL command line client to query, the query results are garbled in Chinese,
It is strange to use other third-party client tools to query Chinese data.
Sogou found the cause of garbled characters:
In a Chinese operating system, the default language of its command line program is simplified Chinese, and the default encoding is GBK,
But the database encoding for UTF-8 (or other), which causes GBK encoding to parse UTF-8 encoding data to generate Chinese garbled characters.
Solution:
Run the command set character_set_results = gbk;
Set the encoding of the current command line prompt query result to GBK.
PS:
This command is only valid for the current command line window. If you exit, open the command line again,
You need to re-execute this command, otherwise the query results are still garbled in Chinese.