It is important to specify the encoding and sorting rules when creating a database in MYSQL. Many developers use the default encoding, but from my experience, coding databases can avoid garbled characters caused by import and export. Www.2cto.com the standard we follow is that the encoding of databases, tables, fields, and pages or texts must be unified by many mysql database tools (except phpmyadmin, Which I occasionally use and is highly functional and slow) the database encoding cannot be specified during creation. You can change it to my. ini to solve this problem, but you need to restart mysql, but use the following statement to make it more effective GBK: create database 'database name' default character set gbk COLLATE gbk_chinese_ci; UTF8: create database 'test2' default character set utf8 COLLATE utf8_general_ci Note: if not through my. the content set in the ini configuration file is valid only in the current status and becomes invalid after the Database Service is restarted. So if you want to avoid garbled characters, you only need to modify my. INI file. You can specify UTF8 when creating a database, as shown in the following code: www.2cto.com | character_set_client | utf8 | character_set_connection | utf8 | character_set_database | utf8 | optional | binary | optional | utf8 | required | latin1 | utf8 pay attention to this Configuration | | latin1 cannot be set to UTF8. garbled characters still appear during interaction. Only when my. SET UTF8 in ini to UTF8 encoding mysql to SET the encoding command www.2cto.com SET character_set_client = utf8; SET character_set_connection = utf8; SET character_set_database = utf8; SET encoding = utf8; /* Note that it is useful. */SET character_set_server = utf8; SET collation_connection = utf8_bin; SET collation_database = utf8_bin; SET collation_server = utf8_bin; my. configure default-charact in ini Er-set = utf8 Connection database setup code jdbc: mysql: // 192.168.0.5: 3306/test? CharacterEncoding = utf8 /************************************ ****************************** * Common Coding UTF-8 in java; GBK; GB2312; ISO-8859-1; corresponding mysql database encoding utf8; gbk; gb2312; latin1 --------------------------- database connection string in the specified character set URL = jdbc: mysql: // yourIP/college? User = root & password = yourPassword & useUnicode = true & characterEncoding = gbk # Mysql