MySQL's default encoding is Latin1, the support for Chinese characters is not good, need to edit the configuration file, set the default MySQL code.
This process is a lot of online tutorials, we can refer to
MySQL Modify encoding format
MySQL modify encoding settings and garbled problems
MySQL Configuration modification under Linux
I met several pits on the way, it was disgusting.
Pit 1, my.cnf file not found
The tutorial says that the path to the MySQL configuration file under Linux is/etc/my.cnf, but cannot be found.
Baidu a bit, said it is possible to appear this situation. If you have experience, you can write one yourself. But I have no experience.
Under console input "Find/-name my*.cnf", there are several. This should be an example provided by MySQL.
Randomly selected a my-small.cnf, according to the tutorial added a few lines to set the code of the statement, put under/ETC/MY.CNF
Console input "service MySQL restart", restart MySQL
Pit 2, server restart failed
After entering the restart command, the error
Removing the my.cnf file can restart normally, possibly MY.CNF syntax.
view MySQL logs , console input "Vim/usr/local/mysql/data/iz28bvt8qj9z.err"
Lock the log content based on the time of the operation and see a line of information:
Internet search, MYSQL5.5 modified character set error: Unknown variable ' Default-character-set=utf8 '
Comment out the "default-character-set = UTF8" in one line of the configuration file [mysqld] and replace it with "character_set_server = UTF8" .
Restart, problem solving
The final my.cnf content is as follows, originally MySQL provides a lot of content, was I in the process of dubug in a breath deleted. It's convenient if you have a friend who has the same problem.
[mysql]default-character-set = utf8[mysqld]#default-character-set = utf8character_set_server = utf8[mysql.server]default-character-set = utf8[mysqld_safe]default-character-set = utf8[client]default-character-set = utf8
[ERROR handle] Configuring MySQL encoding under Linux