MySQL Chinese garbled problem (3)

Source: Internet
Author: User
Tags mysql client

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




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.