The MySQL client is on the DOS interface, but the default character set encoding for the DOS interface is: GBK
(1). MySQL character conversion schematic diagram
(2). View all of the server's encoding methods:
>show variables like ' character% ';
(3). Through the above, if you do not want to appear in Chinese garbled situation, you need to specify the client's encoding method, the connector encoding, the return data encoding method;
#设置客户端为GBK:
>set CHARACTER_SET_CLIENT=GBK;
#设置连接器使用UTF8
>set Character_set_connection=utf8;
#如果有返回值, set the GBK encoding of the return value:
>set CHARACTER_SET_RESULTS=GBK;
Note: These are limited to the current DOS black screen interface, and are restored as they were after reboot. If you want to completely change, then go to the MySQL installation file, modify the My.ini configuration file, find the client: DEFAULT_CHARACTER_SET=GBK;
(Only the client is modified)
(4) Use Set names GBK; (You can set the same three formats in one shot)
(5) Summary: Understand the above schematic diagram, so solve the garbled problem two kinds of scenarios:
1> The current MySQL client modifies the input and output of the MySQL environment variable to GBK or GB2312 (currently active)
2> Modify the My.ini file in the MySQL directory to change the client's default encoding to GBK or GB2312, note that the MySQL service needs to be restarted