Mysql inserting garbled characters
Cause:
The character encoding of the database table and the insert statement does not match or the database table encoding does not support Chinese characters.
Solution:
Modify the character encoding in table to UTF-8 (or gbk, gb2312)
When the database is linked in the code, add? CharacterEncoding = utf8, for example, jdbc: mysql: // localhost: 3306/db_zhu? CharacterEncoding = utf8
When a garbled code is inserted or modified, run the insert Statement on the mysql terminal to check whether the insert statement is correct. Then print the insert statement in the code to check whether there are garbled characters or question marks ?. Check whether characterEncoding is set for the connection string.
Appendix:
When wamp executes the mysql terminal, mysql-u root is required to have the root permission.
Expansion:
Http://www.cnblogs.com/hongfei/archive/2011/12/29/set-names-utf8.html