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 adjust the MYSQL proofreading rules

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

Share

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

How to adjust the MYSQL proofreading rules, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Adjust MYSQL proofreading rules

Gbk_bin is binary storage. Case sensitive

Gbk_chinese_ci is not case sensitive

1. Server adjustment

[mysqld]

Default-character-set=gbk # added this item to the MYSQL5.1 version-- default-character-set is removed in MySQL 5. 5.

Default-collation=gbk_bin # added this item to the MYSQL5.1 version

Character-set-server=gbk # added this item to the MYSQL5.5 version

Collation-server=gbk_bin # added this item to the MYSQL5.5 version

However, if COLLATTION is not specified during establishment, gbk_chinese_ci will be inherited from the server by default.

Www.2cto.com

two。 Client adjustment

Before show variables like 'collation_%';# adjustment

+-+

| | variable_name | value |

|-

Collation_connection | gbk_chinese_ci |

|-

Collation_database | gbk_bin |-- > after server adjustment (gbk_chinese_ci before adjustment)

|-

Collation_server | gbk_bin |-- > after server adjustment (gbk_chinese_ci before adjustment)

|-

After adjusting mysql > set names' gbk' collate 'gbk_bin';#, take a look at the following

Mysql > show variables like 'collation_%'

+-+

| | variable_name | value |

|-

Collation_connection | gbk_bin |

|-

Collation_database | gbk_bin |

|-

Collation_server | gbk_bin |

|-

Www.2cto.com

3. You can check the rules of the table through the command

Mysql > show full columns from tbz

4. Set up the database and specify rules when the table is set up

CREATE DATABASE IF NOT EXISTS TEST DEFAULT CHARACTER SET gbk COLLATE gbk_bin

CREATE TABLE `tbz` (

`BZ` varchar (3) NOT NULL

`BZMC` varchar (16) NOT NULL

`BZBM` varchar (1) DEFAULT NULL

`SM`varchar (20) DEFAULT NULL

PRIMARY KEY (`BZ`)

) ENGINE=InnoDB DEFAULT CHARSET=gbk COLLATE gbk_bin

5. How to change the default value of displaying the current default rule?

Mysql > show collation like 'gbk%'

+-+-- www.2cto.com

| | Collation | Charset | Id | Default | Compiled | Sortlen | |

|-

| | gbk_chinese_ci | gbk | 28 | YES | YES | 1 |

| | gbk_bin | gbk | 87 | | YES | 1 | |

|-

6. Priority of character coding and proofreading rules

MySQL's character set and proofreading rules have four levels of default settings: server level, database level, table level, and field level.

It is recommended that you explicitly specify the character set and proofreading rules when creating the database to avoid being affected by the default values.

This is the answer to the question on how to adjust the MYSQL proofreading rules. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

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