Sometimes because the code needs to modify the MySQL code, Windows modification has a simple graphic interface, Linux people can refer to the following methods
The default login to MySQL allows you to view 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 have some differences, such as the location of the files.) But the content of the settings 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.
Ready-to-use command: CP/USR/SHARE/DOC/MYSQL-SERVER-5.1.52/MY-LARGE.CNF/ETC/MY.CNF
2. Open MY.CNF to modify the encoding
Add Default-character-set=utf8 under [client]
Add Default-character-set=utf8 under [mysqld]
Plus init_connect= ' Set NAMES UTF8 ' (set to use UTF8 encoding when connecting to MySQL database, so that the MySQL database runs as UTF8)
3. Restart MySQL
Service mysqld Restart
Re-enter show variables like '%character% ';
Even if you make the above changes if you create a table directly from the database and then save it in Chinese, the question mark will be taken out. The workaround is to specify that the default character set is UTF8 when creating the database, such as:
Create DATABASE test default character set UTF8;
How to modify MySQL code under Linux