Mysql database Chinese garbled Solution

Source: Internet
Author: User
The article shares the solution to mysql database Chinese garbled Characters During website development. If you encounter the same problem, refer to the following.

The article shares the solution to mysql database Chinese garbled Characters During website development. If you encounter the same problem, refer to the following.

Character Set problems can cause garbled characters, which consumes a lot of energy for developers. For users, follow the method shown in AB below to avoid most coding problems.

A. When installing mysql, the default encoding is latin1. You must manually change it to utf8.

B. Modify the my. ini file

[Mysql] In My. ini corresponds to client parameters.

The corresponding parameter in [mysqld] is the relevant parameter of the database background service.

Both have the default-character-set attribute and set the client to GBK encoding. The background data is stored in utf8 to meet the development environment requirements of most Chinese developers.

Note 1.

Additional instructions on "setting the client to GBK encoding"

Currently, the Windows kernel supports the Unicode character set. The kernel supports all languages and texts around the world, while Windows uses the code page (codepage) to adapt to various countries and regions. Codepage can be understood as the default encoding when we input text in a common cmd window or text editor. This is also the reason why the display encoding Character Set of the database client must be consistent with my. ini settings. If you search for utf8 encoding in cp936, garbled characters are bound.

The codepage corresponding to GBK is CP936.

The method is cmd-> chcp. If the result is displayed, you can confirm that the default input code of the client is 936.

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.