mysql导入报@@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty错误
从阿里云mysqldump的sql文件导入本地库报错
1 2 3 |
[root@localhost ~]# mysql -uroot -p$(cat mysql_password.txt) xxx < /home/backup/xxx/xxx2020-05-07-04-00-01.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1840 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty.
|
原因是阿里云rds自带主从复制,开启了gtid全局事务id用于保证主从复制一致,备份的时候没有忽略gtid,导致导入本地时报错。
方法1、
1 2 3 4 5 6 |
# 查看当前的gtid
mysql> select @@global.gtid_executed\G;
# 清空本地的gtid
mysql> reset master;
Query OK, 0 rows affected (0.04 sec)
|
方法2、删掉sql文件中的 SET @@GLOBAL.GTID_PURGED 2行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
-- MySQL dump 10.13 Distrib 5.7.17, for linux-glibc2.5 (x86_64)
--
-- Host: rm-xxx.mysql.rds.aliyuncs.com Database: xxx
-- ------------------------------------------------------
-- Server version 5.7.25-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
SET @MYSQLDUMP_TEMP_LOG_BIN = @@SESSION.SQL_LOG_BIN;
SET @@SESSION.SQL_LOG_BIN= 0;
--
-- GTID state at the beginning of the backup
--
SET @@GLOBAL.GTID_PURGED='6822560b-3659-11e8-afba-7cd30adaf22a:1-33310212,
79abd425-3659-11e8-8eeb-7cd30adaf28e:1-36989543';
|
方法3、
1 2 |
/usr/local/mysql/bin/mysqldump --set-gtid-purged=OFF
加上--set-gtid-purged=OFF参数再备份,这样就忽略。
|
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/4772.html