MySQL reload privilege for mysqldump during PHP cron job: Use MySQL admin account or create unique user? Security? MySQL reload privilege for mysqldump during PHP cron job: Use MySQL admin account or create unique user? Security? php php

MySQL reload privilege for mysqldump during PHP cron job: Use MySQL admin account or create unique user? Security?


I'm wondering which approach makes more sense or if there's another way to achieve the same results.

The bottom line is that you need a user with certain privileges to run that mysqldump command. While it may seem silly to create a new user just for this one cron job, it's the most straightforward and simple approach you can take that at least gives the outward appearance of lolsecurity.

Given that this is a stopgap measure until you can get replication up and running, there's no real harm being done here. Doing this by replication is totally the way to go, and the stopgap measure seems sane.

Also, when it comes time to get replication going, xtrabackup is your friend. It includes binary log naming and position information with the snapshot it takes, which makes setting up new slaves a breeze.


I just ran across this same error (probably on the same site you were working on :) ), even when running as the MySQL root user. I managed to get around it by not specifying --skip-add-locks, e.g. this worked:

/usr/bin/mysqldump -u USERNAME -pPW DATABASE_NAME --skip-lock-tables --single-transaction --flush-logs --hex-blob