mysqldump Warning: Using a password on the command line interface can be insecure.

1. 对于MYSQL DBA经常做大数据导出的工作的人,mysqldump是经常用到的,而5.6会在指定了明密码的情况下把错误信息包含到导出文件里面

因为数据太大,导出时间长,所以需要做后台运行,例如:

nohup mysqldump -uroot -ptest --all-databases --master-data >test.sql &

然而到完后发现导入时报错

[root@CentOS6 ~]# mysql test <test.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: Using a password on the command line interface can be insecure.






/' at line 1
[root@CentOS6 ~]# 

2.查看导出文件发现,开头多了waring一行,可以用sed -i '1d'  test.sql 编辑 , 但是很大的文件会很长时间,考虑重新导出,千万别用vi编辑,不然100g可能就变成几个g了。

[root@test]# head -n 10 test.sql 
Warning: Using a password on the command line interface can be insecure.
-- MySQL dump 10.13  Distrib 5.6.27, for Linux (x86_64)
--
-- Host: localhost    Database: test
-- ------------------------------------------------------
-- Server version	5.6.27-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 */;
[root@test]# 


3.为了避免以上的情形,我们可以考虑用mysqldump的一个参数 --result-file 来实现

nohup mysqldump -uroot -ptest --all-databases --master-data  --result-file=test.sql & 

当然还有其他方式,比如写bash脚本等,但是最直接的解决方式就是用参数






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值