Settings for the MySQL character set

Source: Internet
Author: User

Notice: article written based on Ubuntu system

1. About the MySQL character set

MySQL Character set support (Character set supports) has two aspects:

The character set (Character set) and the Sort method (Collation).

MySQL support for character sets is refined to four levels: server, database, data table (table), and connection (connection).

MySQL Specifies the character set that can be refined to a database, a table, a column, and what character sets should be used.

2. View the MySQL character set 2.1. View settings for a character set

Mysql> Show variables like ' character_set_% ';

2.2. View character set sorting settings

Mysql> Show variables like ' collation_% ';

3. Modifying the MySQL character set 3.1 modifying the server-level character set

A. Temporary modifications

Mysql>set GLOBAL Character_set_server=utf8;

B. Permanent modification

Open/etc/mysql/my.cnf, add Character-set-server=utf8 after [mysqld]

3.2 Modifying the database level

A. Temporary changes

Mysql>set GLOBAL Character_set_database=utf8;

B. Permanent changes

You can change the server level.

3.3 Modifying table-level

Mysql>alter TABLE table_name DEFAULT CHARSET UTF8; Changed after permanent effect

3.4 Modifying a column-level modification example

Mysql>alter TABLE ' products ' change ' Products_model ' VARCHAR (CHARACTER SET UTF8 COLLATE utf8_general_ci NULL DEFA ULT NULL; Changed after permanent effect

3.5 Changing the connection character set

A. Temporary change:mysql> SET GLOBAL character_set_client;

B. Permanent change: open/etc/mysql/my.cnf, add Default-character-set=utf8 after [client]

notice:3.1 and 3.5 need to restart Mysql:service mysql restart

Settings for the MySQL character set

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.