MySql Chinese garbled problem (3), mysql Chinese garbled Problem

Source: Internet
Author: User

MySql Chinese garbled problem (3), mysql Chinese garbled Problem

The MySql client is on the dos interface, but the default character set encoding method on the dos interface is: GBK

(1) MySql character conversion Principle


(2). view all the encoding methods of the server:

> Show variables like 'character % ';


(3). If you do not want to see Chinese garbled Characters During viewing, you must specify the encoding method of the client, the encoding method of the connector, and the encoding method of the returned data;

# Set the client to GBK:
> Set character_set_client = gbk;

# Set UTF8 for the connector

> Set character_set_connection = utf8;

# If a return value exists, set the returned value to be encoded in GBK format:

> Set character_set_results = gbk;

Note: These are only limited to the current dos black screen interface, and are restored after restart. If you want to change it completely, go to the MySql Installation File, modify the my. ini configuration file, and find default_character_set = gbk in the client;

(Only modify the client)

(4) use set names gbk; (you can set these three methods in the same format at one time)



(5) Conclusion: After understanding the above schematic, there are two solutions to solve the garbled problem:
1> modify the input and output MySQL environment variables to GBK or GB2312 on the current MySQL client (currently valid)
2> modify the my. ini file in the MySQL directory and change the default encoding method of the client to GBK or GB2312. Note that you need to restart the MySQL service.





Help. How can I solve the problem of mysql Chinese garbled characters?

What is your mysql version?

When I use mysql 4.x and set utf8, the C # program can read and write Chinese characters normally.
But what I see with the mysql client is garbled

Later I used a mysql-5.6.13-winx64 version, but can C # program can read and write Chinese characters normally.
The mysql client is also normal.

How to solve Mysql Chinese garbled characters

PHP and MYSQL development, garbled issues, pay attention to three places.
Set the character set for connecting to the database.
Character Set of the data table.
Set the character set of the page meta.

Based on your situation analysis,
Whether the cmd command line window is utf8 (generally, in windows, the command line window is not utf8. Note this)
Utf8 used for connection
Whether the data table is utf8

Www.gretheer.com


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.