Problem:
Under normal user permissions to execute mysql-u root-p into the MySQL database, intermediate steps omitted, insert data: INSERT into library name (attribute) values (' Kanji ');
The following prompt appears: Query OK, 1 row affected, 1 Warning (0.00 sec) indicate an error occurred, no insert succeeded, and then execute the SELECT * from table name, the following problem occurs: Garbled or question marks appear in the displayed table.
Solution:
First re-open a terminal window (easy to operate), enter the root user mode
Execute VIM/VI/ETC/MYSQL/MY.CNF (this path is usually the default, depending on the individual's installation)
In the my.cnf file, modify (add) the following in the corresponding location:
[Client]
Default-character-set=utf8
[Mysqld]
Character-set-server=utf8
init_connect= ' Set names UTF8 '
Note: Do not add default-character-set=utf8 here, or the failed to start error will occur when you restart the database!!!!!
[MySQL]
Default-character-set=utf8
After the above content has been modified, save to exit.
Perform service MySQL restart restart MySQL database
Execute Mysql-u root-p (re-login here in order to avoid the problem of not modifying the document before the occurrence of garbled) re-enter the database
Execute show variables like ' character_set_% '; The following appears:
Then execute INSERT into library name (attribute) values (' Kanji ') to reinsert the Chinese data, this will display the Chinese correctly!!! As shown in the following:
Note: This article summarizes the results of many articles in reference to others!!! Hope to provide help to everyone!
Linux environment MySQL database with SQL statements inserted in Chinese display "question mark or garbled" problem solved!