Modifying MySQL encoding in Linux affects project garbled characters. By default, after logging on to mysql, you can use the show variables statement to view system VARIABLES and their values. Mysql> show variables like '% character % '; -------------------------- ---------------------------- | Variable_name | Value | -------------------------- ---------------------------- | character_set_client | latin1 | character_set_connection | latin1 | character_set_database | latin1 | bytes | binary | latency | latin1 | latin1 | character_set _ System | utf8 | character_sets_dir |/usr/share/mysql/charsets/| -------------------------- ------------------------ Description: The following is the setting under the CentOS-6.2 (different versions may be slightly different, for example, 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. cnf 2. 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) 3. restart mysql service mysqld restart and input show variabl again Es like '% character % '; -------------------------- ---------------------------- | Variable_name | Value | -------------------------- ---------------------------- | character_set_client | utf8 | character_set_connection | utf8 | character_set_database | utf8 | optional | binary | optional | utf8 | UTF-8 | character_set_system | utf8 | character _ Sets_dir |/usr/share/mysql/charsets/| ---------------------------- -------------------------- if the above changes are made, create a table in the database and store the table in Chinese. The question mark is displayed. Solution: Specify the default character set utf8 when creating a database, for example, create database test default character set utf8;