Query MySQL garbled _ MySQL in windows command line

Source: Internet
Author: User
Query MySQL garbled characters in the windows command line mysql utf8 garbled in the windows command line

If you want to set the database encoding to utf8, you must first set

The default-character-set attribute is set to utf8, that is

Default-character-set = utf8
Show variable like 'char % ';

Command to check whether all character sets have been changed to utf8. If yes, you have set them successfully.

After setting it to utf8, if you use the management tool to operate mysql, you will find that the Chinese field value is correct, but if you use the command line to query it, garbled characters will occur. when you insert the Chinese field value, the error message "Incorrect string value: '/xD6/xD0/xCE/xC4' for column" is also prompted, which may be related to the encoding page of the windows command line encoded as gbk.

Solution: enter the command before performing the query or update operation.

Set names gbk;

This command can set the encoding with three configurations to gbk.

In this way, Chinese operations can be performed normally.

You can enter

Set names utf8;

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.