Summary of Mysql database garbled characters

Source: Internet
Author: User

 

Today, we have a unique problem with Mysql garbled characters. In the past, we had to solve it in a hurry. This time I really can't stand it. Every time, it's all confused. I decided to make a good exploration and read a lot of materials and blogs before I understood it. Record it first. If there is any error, please correct it. 1. Mysql supports multiple character sets only after Mysql 4.0. This problem only occurs after 4.0. The encoding conversion rule is to convert the encoding from "client encoding" to "server encoding" during data input ", during output, data is converted from "server-side encoding" to "client encoding ". MySQL character set processing is like this: 1. Send a request.

1) the client sends a request to the server.

2) The server converts the requested data from the client character set (character_set_client) to the server connection character set (character_set_connection ).

3) The server then checks the character set of the storage area (table, column,

Then, convert the data from the character set character_set_connection to the character set of the storage area (table, column), and then store or query the data.

2. Return the request.

1) The server converts the character set of the storage area (table, column) to the character_set_connection character set ).

2) convert the server connection character set (character_set_connection) to the result character set (character_set_results) and send it to the client.

 

First, let's take a look at mysql> status;

We can see the settings of the four character sets. 1. Changing the encoding in the my. ini file can change all character sets. 2. set names "uf8" can change the two character sets of Client conn. 3. The encoding set during database creation can change the database. Now that I know the principle, I began to solve the problem today. 1. Chinese is displayed normally elsewhere. However, garbled characters cannot be displayed in CMD. First, I set my. ini to set all character sets to utf8. Personally, utf8 tends to be standard. The database is set to utf8when it is created. However, the command output by CMD is garbled. This is because CMD. That is, dos in windows is not supported by utf8. Therefore, I can convert the encoding method from output to client to GBK. That is, set names gbk. OK. Author JavaNote

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.