简体   繁体   中英

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 (ie, through a link) or run it as a cron job.

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?

  2. 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!

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)?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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