After logging on to mysql by default, you can view the system VARIABLES and their values using the show variables statement. Mysql> show variables like '% character % ';
(The following is the settings under the CentOS-6.2 (different versions may be somewhat different, such as the file location. But the set content should be the same)
1. find the mysql configuration file, copy to the etc directory, the first step is very important to copy/usr/share/doc/mysql-server-5.1.52/my-large.cnf to/etc/my. cnf command: cp/usr/share/doc/mysql-server-5.1.52/my-large.cnf/etc/my. cnf2. open my. add default-character-set = utf8 under [client] to add default-character-set = utf8 and init_connect = 'set NAMES utf8' under [mysqld ]. utf8 encoding is used to connect to the mysql database, to run mysql database as utf8) www.2cto.com
3. restart mysql service mysqld restart and enter show variables like '% character %' again ';
Even if the above changes are made, if the database directly creates a table and then stores the table in Chinese, the question mark is obtained. Solution: Specify the default character set utf8 when creating a database, for example: create database test default character set utf8; Author: GNU sleep