Solve the Problem of Mysql character encoding

Source: Internet
Author: User

Is Chinese character encoding always difficult for a well-known mysql database?

This article uses mysql5.5 as an example. The installation method is considered here. To ensure that the program smoothly inserts data into the database without any character problems, mysql encoding is generally set to utf8 encoding. However, character encoding problems often occur in the command line mode:

1) If you want to directly insert Chinese Characters in command line mode, insertion fails. 1)

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/22531G237-0.png "border =" 0 "alt =" "/>

Figure 1 incorrect string value)

 

2) use a program such as Java) to insert data successfully. The navicate tool is used to display the data in Chinese, and the mysql Workbench tool still queries data in Chinese ), the query results in command line mode are garbled)

 

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/22531Gc3-1.png "border =" 0 "alt =" "/>

Figure 2 shows Chinese characters)

 

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/22531K106-2.png "border =" 0 "alt =" "/>

Figure 3 shows garbled data)

 

For the solution, see the following link:

"Flying Butterfly" blog, http://jinyabo.blog.51cto.com/3411101/1186030

 

But there is a problem.

Declaration: verification is not required because it is already in progress.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/22531IL9-3.png "border =" 0 "alt =" "/>

Figure 4 setting failed)

 

At this time, I had to go to the my. ini file and check the key points)

1) Default-character-set = utf8

Default encoding settings, which should be consistent with the operating system code)

Change to default-character-set = gbk) gb18030 is not supported)

2) Character-set-server = utf8 server encoding settings)

It does not need to be changed by default, but if it is not utf8, it is recommended to change it to utf8)

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/22531MF1-4.png "border =" 0 "alt =" "/>

Figure 5 encoding)

 

Then go to the command line mode again and execute query 6)

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/22531G547-5.png "border =" 0 "alt =" "/>

Figure 6 query successful)

 

Experience: You can understand default-character-set as the client, and character-set-server as the server. The client and server encoding are consistent, of course, the best partner! In short, we should observe more and study more configuration files. This kind of problem may not be seen every time, but once it appears, it is very scratching your head. For example, I used to install utf8 every time. After three years of use, Chinese characters can be inserted, but this time I switched to a 64-bit operating system. If the problem occurs, you can use google or Baidu. However, it is not necessarily the answer you want. You can study it on your own and solve it!

 

Thanks: Hua feibutterfly's summary of MySQL database garbled characters

This article is from the IT traveler blog, please be sure to keep this source http://fylxopensource.blog.51cto.com/1328715/1188669

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.