I am writing a small website job today. I can use jsp to insert data to MySQL in Ubuntu 8.10. Both English and numbers can be inserted, but Chinese characters won't work. I used all the jsp Chinese characters. I tried to use mysql query browser (a MySQL GUI tool) to insert Chinese data here, the result returns the incorrect string value ..... I understand the cause of this error. Then I used baidu and google to search and finally solved the problem. Now I want to share my experience as follows:
First stop MySQL service: sudo/etc/init. d/mysql stop
Then edit the MySQL configuration file sudo gedit/etc/mysql/my. cnf.
Add the following content to the [client] section of the my. cnf File
Default-character-set = utf8
[Mysqld_safe]
Default-character-set = utf8
[Mysqld]
Default-character-set = utf8
[Mysql]
Default-character-set = utf8
Restart the MySQL service,
Sudo/etc/init. d/mysql start
Enter the MySQL Command Prompt and enter the following command:
Mysql> show variables like '% char % ';
If the items in the list are the same as the following, the configuration is successful,
+ ---------------------- + ---------------------
| Variable_name | Value
+ ----------------------- + ---------------------
| Character_set_client | utf8
| Character_set_connection | utf8
| Character_set_database | utf8
| Character_set_filesystem | binary
| Character_set_results | utf8
| Character_set_server | utf8
| Character_set_system | utf8
| Character_sets_dir |/usr/share/mysql/charsets/
Then, delete the original database and create a new database (I did this, but if I did not, it would still cause errors)
Now Chinese data can be inserted
Successful
Linuxidc Disclaimer: This article only represents the author's personal opinion and has nothing to do with the help house. Its originality, as well as the statement text and content in this article have not been confirmed by this site, this article and all or part of the content, the authenticity, integrity, timeliness of this site do not make any warranty or commitment, for your reference only, please verify the relevant content on your own.