Get the App
SLTechnology News&Howtos  ›  Database  › 

How to adjust the character set of MySQL data Table

Shulou Source: shulou.com Published: 2022-06-01 18:32:43 09月22日 Update

Let's learn how to adjust the MySQL data table character set, I believe you will benefit a lot after reading, the text is not much in the essence, hope that how to adjust the MySQL data table character set this short content is what you want.

The structure of the data table T1 table.

Mysql > show create table T1\ G

* * 1. Row *

Table: t1

Create Table: CREATE TABLE `t1` (

`id`int (11) NOT NULL AUTO_INCREMENT

`roomt`varchar (30) NOT NULL DEFAULT''

PRIMARY KEY (`id`)

UNIQUE KEY `uniq_ roomt` (`roomt`)

) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8

1 row in set (0.00 sec)

1. Adjust the default charset to utf8mb4.

Mysql > alter table T1 default charset utf8mb4

Query OK, 0 rows affected (0.07 sec)

Records: 0 Duplicates: 0 Warnings: 0

Mysql > show create table T1\ G

* * 1. Row *

Table: t1

Create Table: CREATE TABLE `t1` (

`id`int (11) NOT NULL AUTO_INCREMENT

`roomt`varchar (30) CHARACTER SET utf8 NOT NULL DEFAULT''

PRIMARY KEY (`id`)

UNIQUE KEY `uniq_ roomt` (`roomt`)

) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4

1 row in set (0.00 sec)

two。 Adjust the account field collate to utf8mb4_bin.

Mysql > alter table T1 modify column account varchar (30) collate utf8mb4_bin not null default''

Query OK, 0 rows affected (0.71 sec)

Records: 0 Duplicates: 0 Warnings:

Mysql > show create table T1\ G

* * 1. Row *

Table: t1

Create Table: CREATE TABLE `t1` (

`id`int (11) NOT NULL AUTO_INCREMENT

`roomt`varchar (30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT''

PRIMARY KEY (`id`)

UNIQUE KEY `uniq_ roomt` (`roomt`)

) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4

1 row in set (0.00 sec)

3. Adjust the default charset, and each field charset to utf8.

Mysql > alter table T1 convert to charset utf8

Query OK, 0 rows affected (1.65 sec)

Records: 0 Duplicates: 0 Warnings: 0

Mysql > show create table T1\ G

* * 1. Row *

Table: t1

Create Table: CREATE TABLE `t1` (

`id`int (11) NOT NULL AUTO_INCREMENT

`roomt`varchar (30) NOT NULL DEFAULT''

PRIMARY KEY (`id`)

UNIQUE KEY `uniq_ roomt` (`roomt`)

) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8

1 row in set (0.00 sec)

After reading this article on how to adjust the character set of MySQL datasheets, many readers will want to know more about it. For more industry information, you can follow our industry information section.

Tags: Adjustments data datasheets characters character sets content fields more industry affirmation benefit a lot information text friends columns articles structure readers information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology NVidia Microsoft MySQL