Linux environment MySQL database with SQL statements inserted in Chinese display "question mark or garbled" problem solved!

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.