我编写了一个脚本来备份我的 MySQL 数据库,使用:
mysqldump --opt --all-databases -u user -pmypassword > myDump.sql
一个 cron 每天晚上启动它并将结果 scp 到另一台服务器。
mypassword
在我的脚本中清晰显示,每个人都可以通过适当的权限看到它。我也被告知/proc 问题(可以看到 cmd 运行)。
MySQL 文档说:
Specifying a password on the command line should be considered insecure. See Section 7.6, "Keeping Your Password Secure".
我在任何地方都没有找到这个神奇的 7.6 部分。
处理自动mysqldump和密码安全的好习惯是什么?
最佳答案
引用 MySQL 文档(http://dev.mysql.com/doc/refman/5.1/en/password-security-user.html):
Store your password in an option file. For example, on Unix you can list your password in the [client] section of the .my.cnf file in your home directory:
[client] password=your_pass
To keep the password safe, the file should not be accessible to anyone but yourself. To ensure this, set the file access mode to 400 or 600. For example:
shell> chmod 600 .my.cnf
To name from the command line a specific option file containing the password, use the
--defaults-file=file_name
option, wherefile_name
is the full path name to the file.
关于cron 启动的 mysqldump 和密码安全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6861355/