Set character sets and sorting methods for MySQL

Source: Internet
Author: User

1. edit/etc/My. CNF file, add "default-character-set = utf8" under "[client]"
2. edit/etc/My. CNF file, add "default-character-set = utf8" under "[mysqld]"
3. restart MySQL service
# sudo/etc/init. d/mysqld restart
* view the system character set and sorting method

Mysql> show variables like 'collation/_ % '; <br/> + ------------------------ + -------- + <br/> | variable_name | value | <br/> + bytes + -------- + <br/> | character_set_client | utf8 | <br/> | character_set_connection | utf8 | <br/> | character_set_database | utf8 | <br/> | character_set_filesystem | binary | <br/> | bytes | utf8 | <br/> | character_set_server | utf8 | <br/> | character_set_system | utf8 | <br/> + ------------------------ + -------- + <br/> mysql> show variables like 'character/_ set/_ % '; <br/> + response + --------------- + <br/> | variable_name | value | <br/> + response + --------------- + <br/> | collation_connection | utf8_general_ci | <br/> | collation_database | utf8_bin | <br/> | collation_server | utf8_general_ci | <br/> + -------------------- + ----------------- +

 

4. Set the database Character Set
Mysql> create database <database> default Character Set utf8 default collate utf8_bin;
Or modify an existing database.
Mysql> alter database <database> default Character Set utf8 default collate utf8_bin;

* View all collation supported by MySQL
Mysql> show collation;

 

 

 

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.