Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the MySQL character set

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the knowledge of "how to use the MySQL character set". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Recently migrated mysql and upgraded mysql version, encountered a lot of garbled (mainly facial expression problems), so write it down.

The mysql character set supports four levels of character sets and corresponding comparison rules, such as character_set_server at server level, character_set_database at database level, and character sets at table level and column level, for example:

Create database test CHARSET set utf8mb4 COLLATE utf8_general_ci

In addition, character set comparison should also follow the rules, the more commonly used comparison rule is utf8_general_ci.

General configuration when the server starts:

[mysqld] character_set_server = utf8mb4

Use the utf8mb4 character set whenever possible when installing and creating library tables.

For the client (such as program driver, mysql toolset), there are three character set-related system variables, namely character_set_client,character_set_connection,character_set_results, which are used to encode and decode on the client side and interact with the database.

These three parameters are actually specified once through default-character-set or set names.

The specific problems encountered are:

The specified default-character-set for 1:mysql import and export is utf8mb4, or garbled code may occur.

2: the server-level character set is configured as utf8mb4, and even if not specified, libraries, tables, and columns will inherit the server-level configuration.

3. The MySQL toolset, which displays the specified-default-character-set character set as much as possible, such as:

[client] default-character-set=utf8mb4 [mysql] default-character-set=utf8mb4

4: if there is a proxy, be sure to specify the character set on the proxy

5: if you don't know if there is a problem, check and modify it through phpmyadmin, especially the mysql statement that it executes.

6: specify the character set when compiling, such as:

Cmake-DDEFAULT_CHARSET=utf8mb4-DEXTRA_CHARSETS=all-DDEFAULT_COLLATION=utf8mb4_general_ci "how to use the MySQL character set" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report