A slight change in the settings of the mysql character set (for Chinese garbled characters, mysql character set needs to be set) does not cause a headache due to character set problems, but also makes a mistake. it is better to save the time and avoid major accidents, alas, it is very necessary to clarify the points:
For example, my work environment is CTR + redhat5 + mysql5.5
When importing SQL statements, you must pay attention to three places: (here we take the UTF-8 character set as an example)
Character set problems:
1. the crt should be changed to UTF-8 xin
2. change the linux character set locale
LANG = en_US.UTF-8
3. in mysql, the client must be:
Mysql>/s
...
Server characterset: utf8
Db characterset: utf8
Client characterset: latin1
Conn. characterset: latin1
...
Mysql> set names utf8; here the character set of the temporary change client is UTF-8, this is caused by historical issues, only temporary change.
Query OK, 0 rows affected (0.00 sec)
Mysql>/s
...
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
...
In another case, the character set can take effect permanently. the method is as follows:
For Chinese garbled characters, you need to set the mysql character set:
Use the find command to find the cnf file. Remember not to go to my. cnf because it does not necessarily exist, but should look for *. cnf.
# Find/-name '*. cnf'
/Usr/share/doc/MySQL-server-5.5.27/my-huge.cnf
/Usr/share/doc/MySQL-server-5.5.27/my-large.cnf
/Usr/share/doc/MySQL-server-5.5.27/my-medium.cnf
/Usr/share/doc/MySQL-server-5.5.27/my-small.cnf
/Usr/share/doc/MySQL-server-5.5.27/my-innodb-heavy-4G.cnf
/Usr/share/doc/kpathsea-2007/kpathsea_defaults/texmf-kpathsea-defaults.cnf
/Usr/share/mysql/my-huge.cnf.
/Usr/share/mysql/my-large.cnf.
/Usr/share/mysql/my-medium.cnf.
/Usr/share/mysql/my-small.cnf.
/Usr/share/mysql/my-innodb-heavy-4G.cnf.
/Etc/pki/tls/openssl. cnf
Copy one.
# Cp/usr/share/mysql/my-huge.cnf/etc/my. cnf
Open my. cnf and modify the encoding.
# Vi/etc/my. cnf
Below mysql5.5:
Add under [mysqld]
Default-character-set = utf8
Add under [client]
Default-character-set = utf8
Change mysql 5.5:
[Client]
Default-character-set = utf8
[Mysqld]
Character-set-server = utf8
Restart mysql