重庆思庄Oracle、Redhat认证学习论坛

标题: WARNING: --master-data is deprecated and will be removed in a future version [打印本页]

作者: jiawang    时间: 2024-10-23 10:13
标题: WARNING: --master-data is deprecated and will be removed in a future version
Mysql 版本:/usr/local/mysql/bin/mysql Ver 8.0.26 for Linux on x86_64 (MySQL Community Server - GPL)


报错:mysqldump全库备份后,导入时报错
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WARNING: --master-data is deprecated and will be removed in a future version. Us' at line 1


操作过程:
mysqldump全库备份,操作命令如下:
mysqldump -uroot -p****** --single-transaction --master-data=2 --routines --flush-logs --flush-privileges --all-databases --set-gtid-purged=OFF > fulldb_20220223.sql


后续导入新库报错:
mysql -uroot -p < fulldb_20220223.sql
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WARNING: --master-data is deprecated and will be removed in a future version. Us' at line 1



查看导出的文件头部:
# head -10 fulldb_20220223.sql
WARNING: --master-data is deprecated and will be removed in a future version. Use --source-data instead.
-- MySQL dump 10.13  Distrib 8.0.26, for Linux (x86_64)
--
-- Host: localhost    Database:
-- ------------------------------------------------------
-- Server version       8.0.26


/*!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 */;
导出的sql文件里多了一行Waring,提示master-data将废弃,建议使用source-data。


原因分析:
       该情况属于Bug。Mysqldump 8.0.26新版本引入新参数,有waring提示正常,但错误信息本不该直接写到sql文件里的。MySQL Bugs: #104769: CLI options deprecation warnings of mysqldump are printed to stdout


解决方法:


        方法一:
        导出时就不使用master-data,改为source-data替代。这属于新版本8.0.26 mysqldump 的改变,新引入的参数。
9522067185bcbba5e1.png
登录/注册后可看大图