Character Set in mysql

Source: Internet
Author: User

Character Set in mysql
Overview

In essence, a computer only recognizes binary code. Therefore, no matter the computer program or the data it processes, it must eventually be converted into a binary code before the computer can recognize it. People encode every character symbol for computer identification and processing. This is the origin of the Computer character set.

Select the appropriate Character Set

MySQL5.6 supports dozens of character sets, including UCS-2, UTF-16, UTF-16LE, UTF-32, UTF-8, utf8mb4 and other Unicode character sets, select character set can consider the following factors:

To meet the application support language requirements, if the application needs to process a variety of text, you should choose Unicode encoding, For MySQL, It is recommended for UTF-8; if the application involves existing data import, the compatibility of database character sets with existing data should be fully considered. If the database only needs to support general Chinese, a large amount of data, high performance requirements, then you can choose double byte Fixed Length Encoding of the Chinese character set, such as GBK, because compared with the UTF-8, GBK is relatively small, each Chinese Character occupies only 2 bytes, UTF-8 Chinese characters need 3 bytes; on the contrary, if the main processing English characters, select UTF-8 better, because GBK, UCS-2, the Spanish characters in the UTF-16 are encoded in 2 bytes. If the database requires a lot of character operations, it is better to select a fixed-length character set. If all client programs support the same character set, the character set is preferentially selected as the character set of the database.

Comparison of common character sets:

MySQL Character Set MySQL supports using different character sets for different fields in the same server, database, or even table. The MySQL character set includes character sets and verification rules. The character set is used to define the way MySQL stores strings, the collation is used to define the string comparison method, and the character set and verification rules are one-to-many relationships. MySQL has four levels of default settings: Server-level, database-level, table-level, and field-level. You can set character-set-server = UTF-8 In the MySQL configuration file (my. cnf. In practical applications, Character Set and collation settings between the client and server also exist. MySQL provides three parameter settings: character_set_client, character_set_connection, and character_set_results, which respectively represent the character sets of the client, connection, and returned results. Generally, these three parameters are not set separately. You can use the command set names *** to set them, or set default-character-set = UTF-8 in my. cnf.

The meanings of MySQL Character Set system variables are as follows:

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.