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.