mysql匯入報@@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_EXECUTED is empty錯誤
阿新 • • 發佈:2021-11-22
從阿里雲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