mysql 5.6版本之后,使用 mysqldump dbName -r - p > bs.sql 会报警告。
具体原因请看:mysql官网文档7.1.2.1 End-User Guidelines for Password Security
MySQL users should use the following guidelines to keep passwords secure.
When you run a client program to connect to the MySQL server, it is inadvisable to specify your password in a way that exposes it to discovery by other users. The methods you can use to specify your password when you run client programs are listed here, along with an assessment of the risks of each method. In short, the safest methods are to have the client program prompt for the password or to specify the password in a properly protected option file.
大意就是,在命令行输入密码,不安全。因此,它也给出了几个解决方案。
其中就用利用my.cnf(linux下)/my.ini(window)加入密码的写法。
[client]
host=your_host
user=your_user
password=your_pass
对应的,mysqldump的备份写法是如下:
mysqldump --defaults-extra-file=../my.ini dbName >dbName.sql