1. List all the character sets supported by MySQL:
SHOW CHARACTER SET;
2. Current MySQL server character set settings
SHOW VARIABLES like ' character_set_% ';
3. Current MySQL server character set checksum settings
SHOW VARIABLES like ' collation_% ';
4. Display a database character set
Show create database name;
5. Display a data table character set
Show create table table name;
6. Modifying the database character set
ALTER DATABASE name default character set ' UTF8 ';
7. Modifying the data table character set
ALTER TABLE name default character set ' UTF8 ';
8. Specifying a character set when building a library
Create database name Character Set GBK collate gbk_chinese_ci;
9. Specifying a character set when building a table
CREATE TABLE ' Mysqlcode ' (
' ID ' TINYINT (255) UNSIGNED not NULL auto_increment PRIMARY KEY,
' Content ' VARCHAR (255) Not NULL
) TYPE = MYISAM CHARACTER SET gbk COLLATE gbk_chinese_ci;
Library character set, the following code is missing in MY.CNF:
[Client]
Default-character-set=utf8
[Mysqld]
Default-character-set=utf8
If you do not add the above code, even though the encoding specified at MySQL compile installation is UTF8, the default encoding for the library is still LATIN1, and the table in the library is LATIN1 due to the inheritance of the character set.