mysqldump: flush-privileges option
The documentation is misleading. I read it exactly the same way you do, which isn't what the utility does.
Adding --flush-privileges
causes mysqldump to include the following in the backup file, after dumping the mysql schema...
--
-- Flush Grant Tables
--
/*! FLUSH PRIVILEGES */;
...which of course causes the server where the dump is being restored to re-read the potentially-changed grant tables.
And, that's all it does.
Confirmation of this can be found in the source code for mysqldump "10.13" (the version bundled with MySQL Server 5.5.30):
if (flush_privileges && using_mysql_db == 0)
{
fprintf(md_result_file,"\n--\n-- Flush Grant Tables \n--\n");
fprintf(md_result_file,"\n/*! FLUSH PRIVILEGES */;\n");
}
The using_mysql_db == 0
comparison was confusing at first, but it turns out to be the return value from a string comparison function where "0" means "identical."
In light of Michael-sqlbot's answer, try to keep one more thing in perspective.
The only time using --flush-privileges
is good for a mysqldump is when
- you dump
--all-databases
(which includes themysql
schema) - you dump the
mysql
schema only.
What's even more superficial about the --flush-privileges
option for mysqldump is that you can just append the command to the output yourself like this:
mysqldump --all-databases --routines --triggers > MySQLData.sql
echo "FLUSH PRIVILEGES;" >> MySQLData.sql
This assumes you cared to remember this. That's why the --flush-privileges
option was added to mysqldump as a reminder.