当前位置:Gxlcms > 数据库问题 > pt-osc 变更时遇到 “MySQL error 1300” 报错问题解决

pt-osc 变更时遇到 “MySQL error 1300” 报错问题解决

时间:2021-07-01 10:21:17 帮助过:3人阅读

.0.1 --port=3306 --charset=utf8mb4 D=db_main,t=tb_main --alter "modify sGuid varchar(512) DEFAULT NULL COMMENT ‘sGuid‘" --no-check-alter --no-check-replication-filters --alter-foreign-keys-method=auto --recursion-method=none --critical-load="Threads_running=50" --max-load="Threads_running=100" --print --execute

执行时报错:

  1. <span style="color: #800080;">2019</span>-<span style="color: #800080;">07</span>-25T11:<span style="color: #800080;">03</span>:<span style="color: #800080;">00</span> Error copying rows from `db_main`.`tb_main` to `db_main`.`_tb_main_new`: <span style="color: #800080;">2019</span>-<span style="color: #800080;">07</span>-25T11:<span style="color: #800080;">03</span>:<span style="color: #800080;">00</span> Copying rows caused a MySQL error <span style="color: #800080;">1300</span><span style="color: #000000;">:
  2. Level: Warning
  3. Code: </span><span style="color: #800080;">1300</span><span style="color: #000000;">
  4. Message: Invalid utf8 character </span><span style="color: #0000ff;">string</span>: <span style="color: #800000;">‘</span><span style="color: #800000;">CE</span><span style="color: #800000;">‘</span>

 

在 percona 官网找到原因: https://jira.percona.com/browse/PT-1528 ,这里直接贴出原因。

  1. <span style="color: #000000;">pt-online-schema-change could emit utf8 errors for binary PK:
  2. Workaround specify latin1 charset for pt-o-s-c:
  3. pt-online-schema-change --execute --charset=latin1 --chunk-size 2 --alter ‘engine=innodb‘ D=test,t=brokenutf8alter
  4. pt-o-s-c still processes the table correctly (utf8mb4 symbols stored in additional varchar field are valid after pt-o-s-c run). 4-byte changes also processed correctly by pt-o-s-c triggers.
  5. Possible fix: use binary or hex literals instead of ‘?‘ substitution.</span>

 

解决

用 latin1 字符集代替 utf8

  1. pt-online-schema-change --user=xxxx--password=xxxxxx --host=<span style="color: #800080;">127.0</span>.<span style="color: #800080;">0.1</span> --port=<span style="color: #800080;">3306</span><span style="color: #000000;"> </span>--charset=latin1 D=db_main,t=<span style="color: #000000;">tb_main </span>--alter <span style="color: #800000;">"</span><span style="color: #800000;">modify sGuid varchar(512) DEFAULT NULL COMMENT ‘sGuid‘</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span>--no-check-alter --no-check-replication-filters --alter-foreign-keys-method=auto --recursion-method=<span style="color: #000000;">none </span>--critical-load=<span style="color: #800000;">"</span><span style="color: #800000;">Threads_running=50</span><span style="color: #800000;">"</span> --max-load=<span style="color: #800000;">"</span><span style="color: #800000;">Threads_running=100</span><span style="color: #800000;">"</span><span style="color: #000000;"> </span>--print --execute

 

pt-osc 变更时遇到 “MySQL error 1300” 报错问题解决

标签:Fix   character   level   host   ken   sql   targe   ble   line   

人气教程排行