真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

pt-online-schema-change工具的一個選項

使用pt-online-schema-change變更數(shù)據(jù)表某字段長度, 完成后, 查看表結(jié)構(gòu)定義, 卻出現(xiàn)了亂碼...

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)公司!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、小程序開發(fā)、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了雙清免費建站歡迎大家使用!

數(shù)據(jù)表zzzz的表結(jié)構(gòu).

MySQL> show create table zzzz \G

*************************** 1. row ***************************

       Table: zzzz

Create Table: CREATE TABLE `zzzz` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `name` varchar(10) NOT NULL DEFAULT '' COMMENT '物品名稱',

  `category` varchar(10) NOT NULL DEFAULT '' COMMENT '物品分類',

  PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Product infomation'

1 row in set (0.00 sec)

變更字段name的長度為20.

$ pt-online-schema-change --alter "modify name varchar(20) not null default '' comment '物品名稱'" --nocheck-replication-filters --recursion-method=processlist h=192.168.4.45,P=3316,u=mha_mgr,p=123456,D=test,t=zzzz --execute

Found 1 slaves:

db02 -> 192.168.4.46:3316

Will check slave lag on:

db02 -> 192.168.4.46:3316

Operation, tries, wait:

  analyze_table, 10, 1

  copy_rows, 10, 0.25

  create_triggers, 10, 1

  drop_triggers, 10, 1

  swap_tables, 10, 1

  update_foreign_keys, 10, 1

Altering `test`.`zzzz`...

Creating new table...

Created new table test._zzzz_new OK.

Waiting forever for new table `test`.`_zzzz_new` to replicate to db02...

Altering new table...

Altered `test`.`_zzzz_new` OK.

2018-01-15T17:31:27 Creating triggers...

2018-01-15T17:31:27 Created triggers OK.

2018-01-15T17:31:27 Copying approximately 1 rows...

2018-01-15T17:31:28 Copied rows OK.

2018-01-15T17:31:28 Analyzing new table...

2018-01-15T17:31:28 Swapping tables...

2018-01-15T17:31:28 Swapped original and new tables OK.

2018-01-15T17:31:28 Dropping old table...

2018-01-15T17:31:28 Dropped old table `test`.`_zzzz_old` OK.

2018-01-15T17:31:28 Dropping triggers...

2018-01-15T17:31:29 Dropped triggers OK.

Successfully altered `test`.`zzzz`.

完成后, 查看表結(jié)構(gòu), 發(fā)現(xiàn)字段的中文注釋都成了亂碼.

mysql> show create table zzzz \G

*************************** 1. row ***************************

       Table: zzzz

Create Table: CREATE TABLE `zzzz` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `name` varchar(20) NOT NULL DEFAULT '' COMMENT '?‰??“??§°',

  `category` varchar(10) NOT NULL DEFAULT '' COMMENT '????',

  PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Product infomation'

1 row in set (0.00 sec)

解決方法, 使用選項--charset(其文檔說明: Default character set. If the value is utf8, sets Perl’s binmode on STDOUT to utf8, passes the mysql_enable_utf8 option to DBD::mysql, and runs SET NAMES UTF8 after connecting to MySQL. Any other value sets binmode on STDOUT without the utf8 layer, and runs SET NAMES after connecting to MySQL.), 指明字符集為utf8mb4.

$ pt-online-schema-change --alter "modify name varchar(20) not null default '' comment '物品名稱'" --charset=utf8mb4 --nocheck-replication-filters --recursion-method=processlist h=192.168.4.45,P=3316,u=mha_mgr,p=123456,D=test,t=zzzz --execute

瞧, 正常了.

mysql> show create table zzzz \G

*************************** 1. row ***************************

       Table: zzzz

Create Table: CREATE TABLE `zzzz` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `name` varchar(20) NOT NULL DEFAULT '' COMMENT '物品名稱',

  `category` varchar(10) NOT NULL DEFAULT '' COMMENT '????',

  PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Product infomation'

1 row in set (0.00 sec)

關(guān)于pt-online-schema-change工具的更多使用細節(jié), 可參考InnoDB Online DDL續(xù).


網(wǎng)頁標題:pt-online-schema-change工具的一個選項
文章網(wǎng)址:http://weahome.cn/article/jssosp.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部