Solve the Problem of storing mysql Chinese Characters

Source: Internet
Author: User

By default, mysql cannot correctly display Chinese characters. Enter the mysql command:

show variables like 'character_set_%';

 

View Character Set settings
+--------------------------+----------------------------+| Variable_name                 | Value                               |+--------------------------+----------------------------+| character_set_client         | utf8                                  || character_set_connection  | utf8                                 || character_set_database    | latin1                                || character_set_filesystem   | binary                               || character_set_results       | utf8                                  || character_set_server        | utf8                                  || character_set_system       | utf8                                 || character_sets_dir            | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+

 

The Chinese character cannot be displayed because the Value of character_set_database is latin1. Modify the command:
SET character_set_database = utf8 ;
(If the value other than filesystem is not utf8, all values are modified in this way ). After modification, check the character set configuration again to make sure that, after modification, exit mysql (quit) and restart the service, net stop mysql net start mysql re-enter mysql and then delete and re-create the previously created table. We recommend that you use the command before file backup. The method is as follows: Create a mysql. edit SQL in Notepad
Use mysql; create table students (id int unsigned not null auto_increment primary key, name char (30) not null, sex char (10) not null, age tinyint unsigned not null, tel char (13) null default "-"); insert into students values (NULL, "golden open", "male", 20, "13811371377"); insert into students (name, sex, age) values ("10 yuan", "female", 20); select * from students;

 

Then you will find that the Chinese characters are successfully displayed;

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.