Home  >  Article  >  Database  >  Character encoding problem of mysql database

Character encoding problem of mysql database

云罗郡主
云罗郡主forward
2019-01-22 14:17:034212browse

The content of this article is about the character encoding issue of the MySQL database. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. [Recommended tutorial: MySQL tutorial]

1. Display character set settings through the command line

show variables like 'character_set%';

Character encoding problem of mysql database

The first one, character_set_client is The character set encoding of the sent data.

The second one, character_set_connection is the character set encoding when connecting to the database.

The third one, character_set_results is the character set encoding when returning results.

The third one, character_set_database is the character set encoding of the current database.

The fifth one, character_set_server is the character set encoding of the server.

The sixth one, character_set_system is the encoding of the database identifier, such as database name, table name, field name, etc.

Sending process: client (client sending encoding) ------->connection (data connection encoding) ------->[server internal encoding]----- ->Return the result encoding.

2. Character set and verification rules

1. Proofreading rules.

The proofreading rules include three parts: character set encoding_language region_comparison rules.

Character set encoding: gbk, utf8, etc. are all character set encodings.

Comparison rules: ci cs bin three types.

Character encoding problem of mysql database2. Check the collation rules:

show collation like 'xxxx';//模糊查询
show collation;

For example: show collation like 'gbk%'; In fact, this sentence is a query for the library.

3. The difference between gbk_ci and gbk_bin

gbk_ci proofreading rules are not case-sensitive, but gbk_ci is sorted by pinyin. This feature utf8_generation_ci does not exist.

gbk_bin is sorted by character Ascall encoding.

You can pass the statement:

select * from tbl_name order by 字段名;//检验

4. Selection of gbk and utf8

When storing Chinese characters, use the gbk character set, which takes up two bytes. Using utf8 takes up 3 bytes. But gbk is only suitable for mainland websites, and utf8 is suitable for world standards. As for how to choose, it depends on the direction.


The above is the detailed content of Character encoding problem of mysql database. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete
Previous article:What does DDBMS mean?Next article:What does DDBMS mean?