MySQL character set view and settings

Source: Internet
Author: User

1. List all the character sets supported by MySQL:

SHOW CHARACTER SET;

2. Current MySQL server character set settings

SHOW VARIABLES like ' character_set_% ';

3. Current MySQL server character set checksum settings

SHOW VARIABLES like ' collation_% ';

4. Display a database character set

Show create database name;

5. Display a data table character set

Show create table table name;

6. Modifying the database character set

ALTER DATABASE name default character set ' UTF8 ';

7. Modifying the data table character set

ALTER TABLE name default character set ' UTF8 ';

8. Specifying a character set when building a library

Create database name Character Set GBK collate gbk_chinese_ci;

9. Specifying a character set when building a table

CREATE TABLE ' Mysqlcode ' (

' ID ' TINYINT (255) UNSIGNED not NULL auto_increment PRIMARY KEY,

' Content ' VARCHAR (255) Not NULL

) TYPE = MYISAM CHARACTER SET gbk COLLATE gbk_chinese_ci;

Library character set, the following code is missing in MY.CNF:

[Client]

Default-character-set=utf8

[Mysqld]

Default-character-set=utf8

If you do not add the above code, even though the encoding specified at MySQL compile installation is UTF8, the default encoding for the library is still LATIN1, and the table in the library is LATIN1 due to the inheritance of the character set.

Program Access data URL parameter:

Jdbc:mysql://localhost:3306/testcharacter?autoreconnect=true&useunicode=yes&characterencoding=utf8

MySQL character set view and settings

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.