当我们的RDS MySQL 5.7库中有中文表名的时候,如果我们的mysqldump用5.7版本,或者通过AWS DMS 工具的Fullload,均是可以迁移成功的。
测试结果:
1. 使用5.7版本的mysql client/mysqldump:
mysql> create table 测试 (id int,name varchar(20));
Query OK, 0 rows affected (0.24 sec)
mysql> insert into 测试 values(1,'a');
Query OK, 1 row affected (0.06 sec)
[root@ip-10-1-61-250 ~]# mysqldump --version
mysqldump Ver 10.13 Distrib 5.7.29, for Linux (x86_64)
[root@ip-10-1-61-250 ~]# mysqldump -hxxxa1onesgnhw.rds.cn-north-1.amazonaws.com.cn -uroot -p -B test2 --set-gtid-purged=OFF>> test2.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.
-- // 查看 test2.sql:
DROP TABLE IF EXISTS `测试`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `测试` (
`id` int(11) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
-- // Import进RDS MySQL 5.7:
mysql> source /root/test2.sql
mysql> use test2;
Database changed
mysql> show tables;
+-----------------+
| Tables_in_test2 |
+-----------------+
| 测试 |
+-----------------+
1 row in set (0.00 sec)
mysql> select * from 测试;
+------+------+
| id | name |
+------+------+
| 1 | a |
+------+------+
1 row in set (0.00 sec)
2. 使用AWS DMS,fullload可以完全进行中文表的迁移:
DMS 源端:
mysql> show tables;
+-------------------+
| Tables_in_chinese |
+-------------------+
| 测试 |
| test |
+-------------------+
3 rows in set (0.00 sec)
DMS目标端:
mysql> use chinese1;
Database changed
mysql> show tables;
Empty set (0.00 sec)
mysql> show tables;
+--------------------+
| Tables_in_chinese1 |
+--------------------+
| 测试 |
| test |
+--------------------+
3 rows in set (0.00 sec)
如果我们使用DMS,那么可以用mysqldump --no-data语句,将除了table以外的DDL进行迁移,之后用DMS进行所有表的迁移。
3. 无论我们使用如上哪种方法,还请从源端RDS MySQL 执行如下语句,将源端的binlog保留期延长到24小时。以便能够成功进行手动Read Replica的创建,以及CDC阶段的设置。
mysql> call mysql.rds_set_configuration('binlog retention hours', 24); // -- 将日志保留期延长到 24 小时