Macmysql Chinese character garbled troubleshooting _ MySQL

Source: Internet
Author: User
Solve the macmysql Chinese character garbled problem bitsCN.com

Solve mac mysql Chinese character garbled problem

It is best to specify the character encoding when creating a database or table.

Example: create database db_name default character set utf8 default collate utf8_general_ci; // create a database

Create table order_list (

Id int unsigned not null AUTO_INCREMENT,

O_name VARCHAR (40) not null,

O_desc VARCHAR (600) DEFAULT '',

O_category VARCHAR (50) not null,

O_style VARCHAR (20) DEFAULT '',

O_state enum ('1', '0') not null,

O_unitprice double not null,

O_icon VARCHAR (20) not null,

Primary key (id)

) ENGINE = MYISAM AUTO_INCREMENT = 1 default characterset = utf8;

// Create a table

Insert into order_list comment ');

/Insert

If no encoding is specified in the preceding two steps, a second element error is prompted during step 3 insertion because latin encoding is not specified by default and Chinese characters cannot be inserted.

In addition, support for Chinese character output at the customer service end, such as binding to php to output Chinese characters

This requires/usr/local/mysql/my. cnf

Modify the content

Where

[Client]

Default-character-set = utf8

And

Character-set-server = utf8

Yes.

Now you can output Chinese characters.

BitsCN.com

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.