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.
I can then (for example), either call the php function manually (i.e, through a link) or run it as a cron job.
My concern:
Given that the DB is on Ubuntu (Server), o开发者_如何学Gor another Linux flavour, wouldn't this be a bad idea since the next person logging in to the server will recognise the DB password?
Obviously, we're not talking about the root password. 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!
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.
Wouldn't you put the DB password in a PHP file (or ini file) anyway for your real application? Don't you have a phpmyadmin installed (and in it's configuration file you can see the passwords un-encrypted)?
精彩评论