1.Execute the following sentence successfully in MySQL, can be added in Chinese.
Insert into book (bookname,author,publish) VALUES (' Good ', ' Hao ', ' Hao ');
However, executing this INSERT statement in the JSP will cause garbled characters.
Solution: Add the useunicode=true&characterencoding=utf-8 after the URL .
2, import the TXT file in the SQL statement, garbled.
First execute show variables like '%char% ';
+--------------------------+---------------------------------------------------------+
| variable_name | Value |
+--------------------------+---------------------------------------------------------+
| character_set_client | GBK |
| character_set_connection | GBK |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | GBK |
| character_set_server | latin1 |
| character_set_system | UTF8 |
| character_sets_dir | C:\Program files\mysql\mysql Server 5.0\share\charsets\ |
+--------------------------+---------------------------------------------------------+
8 rows in Set (0.00 sec)
Add in My.ini:
[MySQL]
default-character-set=gb2312
[Mysqld]
default-character-set=gb2312
then restart the MySQL service.
Enter the database
ALTER DATABASE charset = gb2312;
also remember to write the set names gb2312 in front of the script that imports the database;
this will be OK.
alter database your database name charset = gb2312;
3, navicat table input data garbled
set names ' GBK ';