cron 启动的 mysqldump 和密码安全

标签 mysql security mysqldump

我编写了一个脚本来备份我的 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, where file_name is the full path name to the file.

关于cron 启动的 mysqldump 和密码安全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6861355/

相关文章:

mysql - 按数据库拆分具有多个数据库的 mysqldump 文件

mysql - Flink数据库连接

mysql - 用户驱动网站的数据库设计

security - 两次加密是好是坏?

mysql - 有哪些方法可以屏蔽 mysqldump?

mySQL数据库文件夹备份脚本

php - MySQL 查询问题 - 匹配连接表上的多个 id

php - 在 Doctrine 中使用 URL 字段

c# - Windows 服务,无法从我的安装程序的构造函数中访问 app.config

php - Symfony2 "This authentication method requires a session"登录检查错误