Home >Backend Development >PHP Tutorial >Character sets in MySQL

Character sets in MySQL

WBOY
WBOYOriginal
2016-07-29 09:13:371088browse

Character set: It describes the encoding used when transmitting graphics or text. It is called Character set.

The relationship between graphics or text and encoding:

is like the following:

"Word" => 10010001 110000111

Character sets in MySQL

Encoding of data storage:

Data is stored on the server side, Who decides which way to encode and store it?

Constraints will eventually be mapped to the field level, so it is the field that determines the encoding.

Determining the encoding of the data is determined by the following scheme:

1. If the field specifies encoding, it is determined by the field,

2. If the field is not specified, just look at the table. If it is specified, the encoding will be determined. 3. If the encoding is not specified in the table, just look at the library. If it is determined, the encoding will be determined by the server. 4. If the library does not have the encoding, the server will Decide by yourself.

Are you sure that the following is the server encoding:

Typical encoding: gbk, utf8 Character sets in MySQL
Client operation, query encoding:

There are two important encodings when the client interacts with the server:

1. The encoding of the data sent by the client

2. The client accepts the encoding of the server

You can use "show variables like "character_set_%"; to display the variables starting with set and they will have the above two values ​​​​,

can only be in the form of gbk under the command line client Character sets in MySQL

Use set variable name = variable value to change the variable value Character sets in MySQL

set names gbk is a quick operation. The above two configurations are changed to the target encoding at the same time! Character sets in MySQL

set names gbk|utf8 depends on the encoding accepted by the client!

The overall process is:

setnames gbk|utf8Character sets in MySQL

The above introduces the character set in MySQL, including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn