MySQL Specifies that the encoding is important when creating a database, many developers use the default encoding, but I use the experience, the development of the database encoding can be largely avoided into the garbled problem of the export.
The standard we follow is that the encoding of databases, tables, fields, and pages or text should be unified.
Many MySQL database Tools (except phpMyAdmin, I occasionally use, the function is slow) do not support the creation of the specified database encoding, of course, can change My.ini to solve this problem, but need to restart MySQL, but with the following statement will be more effective
Gbk:create database test2 DEFAULT CHARACTER SET GBK COLLATE gbk_chinese_ci;
Utf8:create DATABASE ' test2 ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci
Note: If the content is not set through the My.ini configuration file, it is only valid in the current state and is invalidated when the database service is restarted. So if you want to not garbled only modify the My.ini file, the database encoding can be created in the database when you specify UTF8, as follows:
|character_set_client | UTF8 |
| character_set_connection | UTF8 |
| Character_set_database | UTF8 |
| Character_set_filesystem | binary |
| Character_set_results | UTF8 |
| Character_set_server | Latin1 |
| Character_set_system | Utf8
Note This configuration | Character_set_server | Latin1 cannot be set to UTF8
There are still garbled characters when interacting.
All changes to UTF8 are made only if the UTF8 is set in the modified My.ini
-------------------------
MySQL Setup encoding command
SET character_set_client = UTF8;
SET character_set_connection = UTF8;
SET character_set_database = UTF8;
SET character_set_results = UTF8;
SET character_set_server = UTF8;
SET collation_connection = Utf8_bin;
SET collation_database = Utf8_bin;
SET collation_server = Utf8_bin;
Configuring default encoding in My.ini
Default-character-set=utf8
Connection Database Setup Encoding
Jdbc:mysql://192.168.1.1:3306/test?characterencoding=utf8
Common coding UTF-8 in Java; GBK; gb2312;iso-8859-1;
Corresponds to the encoding utf8;gbk;gb2312;latin1 in the MySQL database
MySQL CREATE database specify character set