Chinese garbled characters in MySQL databases have been a problem for a long time, whether it is java Development or php development.
Chinese garbled characters in MySQL databases have been a problem for a long time, whether it is java Development or php development.
Chinese garbled characters in MySQL databases have been a problem for a long time, whether it is java Development or php development.
For the sake of simplicity, I have always set the encoding to UTF-8 on all my JSP pages. At the same time, when I create a MySQL database, I also set it to UTF-8 encoding ,, to prevent inexplicable Chinese garbled characters. However, today we have found a simpler method, without looking into the cause, but it can quickly diagnose and solve Garbled text. (There is no possibility of testing, just generalize)
1. If you find that the Chinese characters inserted in the database are garbled characters on the MySQL console, you can run the "status" command to view the status of the current MySQL database. In the query results, there are several character encoding-related items:
Server characterset: utf8 -- install the MySQL Server as the configured Server code
Db characterset: utf8 -- default database Encoding
Client characterset: utf8 -- Client character encoding
Conn. characterset: utf8 -- encoding used for connection
2. On the MySQL console, use the following command to change the character encoding of the last two items:
Set names gb2312
Then run the "status" command to check whether the encoding of the last two items has changed to "gb2312.
3. query the database again and find that the garbled characters are missing. The Chinese characters are clearly displayed in the database.
4. vice versa. If the last two encoding types are gb2312 in case of Chinese garbled characters, use "set names utf8" and change it to "utf8" encoding.
Please remember!