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 的改变,新引入的参数。
方法二:
原本已经导出好文件,没必要浪费时间重新导出,直接注释掉或者删掉这一行Waring即可。
删除文件里第一行(Linux环境):
sed -i '1d' fulldb_20220223.sql
参考文档
A message "WARNING: --master-data is deprecated ..." is logged in the redirected file by mysqldump (Doc ID 2807795.1) To BottomTo Bottom
MySQL Bugs: #104769: CLI options deprecation warnings of mysqldump are printed to stdout
MySQL :: MySQL 8.0 Reference Manual :: 4.5.4 mysqldump — A Database Backup Program
更多推荐
所有评论(0)