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]#
nohup mysqldump -uroot -ptest --all-databases --master-data --result-file=test.sql &
当然还有其他方式,比如写bash脚本等,但是最直接的解决方式就是用参数