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