After the default login to MySQL, you can view the system variables and their values through the show variables statement.
Mysql> Show variables like '%character% ';
Description: The following are the settings under CentOS-6.2 (different versions may vary, such as the location of the file.) But the contents of the setting should be the same)
1. Find the MySQL configuration file, copy to the ETC directory, the first step is very important
Copy the/usr/share/doc/mysql-server-5.1.52/my-large.cnf to the/ETC/MY.CNF.
Use command: CP/USR/SHARE/DOC/MYSQL-SERVER-5.1.52/MY-LARGE.CNF/ETC/MY.CNF
2. Open MY.CNF Modify Code
Increase Default-character-set=utf8 under [client]
Increase the Default-character-set=utf8 under [mysqld]
At the same time, plus init_connect= ' Set NAMES UTF8 ' (set to connect the MySQL database with the UTF8 encoding, so that the MySQL database to run UTF8)
3. Restart MySQL
Service mysqld Restart
Enter show variables like '%character% ' again;
Even if you do the above changes if the direct database to create a table, and then stored in Chinese, will be taken out of the question mark. The solution is to specify that the default character set is UTF8 when the database is created, such as:
Create DATABASE test default character set UTF8;