在Linux中使用corntab 定时备份MySQL数据库,后期因考虑安全性问题,删除掉了 root@% 用户,发现环境上备份报错了
mysqldump: [Warning] Using a password on the command line interface can be insecure.
mysqldump: Got error: 1449: The user specified as a definer ('root'@'%') does not exist when using LOCK TABLES
经过各方资料查询求证得知,在数据导出前,提交请求会锁定所有数据库中的所有表,保证数据一致。
--lock-all-tables, -x
提交请求锁定所有数据库中的所有表,以保证数据的一致性。这是一个全局读锁,并且自动关闭--single-transaction 和--lock-tables 选项。
mysqldump -uroot -p --host=localhost --all-databases --lock-all-tables
加入-x
参数后
mysqldump -uroot -hIP地址 -p密码 -x 数据库 | gzip > /usr/local/mysql/backup/数据库_$(date +%Y%m%d_%H%M%S).sql.gz
网友评论