How to make your MySQL fully cultural (2) _ MySQL

Source: Internet
Author: User
How to make your MySQL fully cultural (2) see characterset is all gbk and it will be successful.

In the old database of the UTF8 character set, the script for creating a Chinese support table is as follows, and the character set description is added to the field:

Create table 'test'. 'cn '(
'Zh 'CHAR (10) CHARACTER SET
Gb2312 COLLATE gb2312_chinese_ci not null,
'Chinese' INT (11) NOT NULL
)
ENGINE = MYISAM;

Note: character set can write both GB2312 and gbk, and gbk is better than GB2312.

Add a default character set declaration GBK for the newly created database, so that you do not need to declare each field when creating the table. this method looks simple and smooth, with no special Traces. we recommend that you use this method more.

Mysql> create database dbCN DEFAULT
Character set gbk COLLATE gbk_chinese_ci;
Create table 'dbcn'. 'cn '(
'Zh 'CHAR (10) not null,
'Chinese' INT (11) NOT NULL
)
ENGINE = MYISAM;
Mysql> insert into cn values ("Really? ", 1 );

Note: If these scripts cannot be entered using the bin/mysql command line, you can use mysql query Browser or program execution.

Shell> bin/mysql-u root -- default-character-set = gbk-p
Mysql> use test
Mysql> select * from cn;
+ -------- + ------ +
| Zh | Chinese |
+ -------- + ------ +
| Really? | 1 |
+ -------- + ------ +
1 row in set (0.00 sec)
-----------------------------

Finally, modify the startup file/etc/rc. d/rc. mysqld, change path/app/mysql/bin/mysqld_safe, and change path/app/mysql/var/web. add -- user = root -- default-character-set = gbk after pid/app/mysql/bin/mysqld_safe.

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.