简体   繁体   English

有关使用mysqldump备份MySQL DB的担忧

[英]Concern about backing up MySQL DB using mysqldump

If I were to create a MySQL DB backup using mysqldump, and call it using a PHP 'system' or similar function, I have to include the password in the line, in order to automate it. 如果要使用mysqldump创建MySQL数据库备份,并使用PHP“系统”或类似功能调用它,则必须在该行中包含密码以使其自动化。

I can then (for example), either call the php function manually (ie, through a link) or run it as a cron job. 然后,我可以(例如)手动调用php函数(即通过链接)或将其作为cron作业运行。

My concern: 我的顾虑:

  1. Given that the DB is on Ubuntu (Server), or another Linux flavour, wouldn't this be a bad idea since the next person logging in to the server will recognise the DB password? 鉴于数据库位于Ubuntu(Server)或其他Linux版本上,这不是一个坏主意,因为下一个登录服务器的人将识别数据库密码?

  2. Obviously, we're not talking about the root password. 显然,我们不是在谈论root密码。 So the second part of the question is, what privileges could be given to a user account that would only be used to do backups? 因此,问题的第二部分是,可以为仅用于执行备份的用户帐户赋予哪些特权?

Thanks for sharing! 感谢分享!

Wouldn't you put the DB password in a PHP file (or ini file) anyway for your real application? 您是否仍会为您的实际应用程序将DB密码放在PHP文件(或ini文件)中? Don't you have a phpmyadmin installed (and in it's configuration file you can see the passwords un-encrypted)? 您是否没有安装phpmyadmin(并且在配置文件中可以看到未加密的密码)?

You can put the password into a file with appropriately locked-down privileges, then do 您可以将密码放入具有适当锁定权限的文件中,然后执行

cat passwd.txt|mysqldump -p  dump_options_here

At minimum, you'd need SELECT, LOCK_TABLES, and possibly RELOAD if you're in a replication situation and need to flush logs. 至少,如果您处于复制状态并且需要刷新日志,则至少需要SELECT,LOCK_TABLES和RELOAD。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM