Get the App
SLTechnology News&Howtos  ›  Database  › 

How to adjust the MYSQL proofreading rules

Shulou Source: shulou.com Published: 2022-05-31 13:24:48 10月05日 Update

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.

Tags: Adjustment rules proofreading service version character data database question size character set more server help solution easy easy binary priority content Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL MariaDB NVidia Linux Redmi