How to query garbled characters using the MySQL command line Client

Source: Internet
Author: User

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.

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.