Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

3.2. Flexus RDS

3.2.1. 迁移阿里云RDS至华为云RDS

				
[root@aliyun ~]# mysqldump -h aliyun.netkiller.cn -uroot -p watch | gzip > watch.sql.gz
				
			
			
[root@aliyun ~]# scp watch.sql.gz root@newdb.netkiller.cn			
			
			
				
[root@huawei ~]# zcat watch.sql.gz | mysql -h huawei.netkiller.cn -uroot -p development
				
			

使用非root用户,迁移RDS会提示

			
[root@testing ~]# mysqldump -h rm-wz92171y2sukacse6co.mysql.rds.aliyuncs.com -unetkiller -p netkiller | gzip > netkiller.sql.gz
Enter password: 
Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events. 
Warning: A dump from a server that has GTIDs enabled will by default include the GTIDs of all transactions, even those that were executed during its extraction and might not be represented in the dumped data. This might result in an inconsistent data dump. 
In order to ensure a consistent backup of the database, pass --single-transaction or --lock-all-tables or --master-data. 
(failed reverse-i-search)`scp': dnf install -y bzip2 tree psmi^C telnet wget rsync vim-enhanced net-tools bind-utils  			
			
			

如果强行恢复数据库会提示

			
[root@testing ~]# zcat netkiller.sql.gz | mysql -h 192.168.0.219 -uroot -p production
Enter password: 
ERROR 1227 (42000) at line 18: Access denied; you need (at least one of) the SUPER, SYSTEM_VARIABLES_ADMIN or SESSION_VARIABLES_ADMIN privilege(s) for this operation
			
			

解决方法,使用 --set-gtid-purged=OFF 参数备份数据库

			
[root@testing ~]# mysqldump -h rm-wz92171y2sukacse6co.mysql.rds.aliyuncs.com -unetkiller -p netkiller --set-gtid-purged=OFF | gzip > netkiller.sql.gz
Enter password: 
[root@testing ~]# 			
			
			

恢复数据正常

			
[root@testing ~]# scp netkiller.sql.gz root@api.netkiller.cn:/root/
root@api.netkiller.cn's password: 
netkiller.sql.gz                                                                                                                                                                                              100%   18MB 219.8MB/s   00:00    
[root@testing ~]# 		
			
			
			
[root@testing ~]# zcat netkiller.sql.gz | mysql -h 192.168.0.219 -uroot -p production
Enter password: