Character set in MySQL

Source: Internet
Author: User
: This article mainly introduces the character set in MySQL. if you are interested in the PHP Tutorial, you can refer to it. Character set: it is the encoding used to describe graphics or text during transmission.

Relationship between graphics or text and encoding:

It is like the following:

"Word" => 10010001 110000111


Data storage encoding:

Which encoding method is used to store data on the server?

Constraint is ultimately mapped to the field level, so the encoding should be a field,

Data encoding is determined by the following scheme:

1. if encoding is specified for a field, it is determined by the field,

2. if the field is not specified, check the table and confirm the encoding if it is specified.

3. if no encoding is specified in the table, check the database. If encoding is determined

4. if the library is not encoded, it is determined by the server itself.

Are you sure you want to encode the server:


Typical encoding: gbk and utf8

Client operation, query encoding:

When the client interacts with the server, there are two important codes:

1. encoding of data sent by the client

2. the client accepts the server code.

You can use "show variables like" character_set _ % "; to display variables with the beginning of set with the above two values,


The command line client can only be in the gbk format


Use set variable name = variable value to change the value

Set names gbk is a quick operation, which changes the above two configurations to the target encoding at the same time!

Set names gbk | utf8 depends on the encoding that the client can accept!

The overall process is:


Setnames gbk | utf8

The above introduces the character set in MySQL, including some content, and hopes to help those who are interested in the PHP Tutorial.

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.