Bug #29043 Add mysqldump option to dump privileges in GRANT format
Submitted: 12 Jun 2007 6:37 Modified: 13 Jun 2007 9:54
Reporter: Alexander Keremidarski Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: mysqldump Command-line Client Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any

[12 Jun 2007 6:37] Alexander Keremidarski
The prefered way of setting privileges in MySQL is by using GRANT commands. 

However there is no way to dump such privileges in a file which can be reused for restoring privileges of particular customer or set of customers. 

MySQL has SHOW GRANTS syntax which can dump the privileges for particular users. 


mysql -e "SHOW GRANTS .." > file 

doesn't work well because it is not supposed to produce list of executable statements.

mysqldump mysql 

also can't do the job because the privilege information is spread across several tables. 

It would be best to introduce an option to mysqldump for that purpose. 

Something like:

mysqldump --grants-for='user'@'host'

Some variant for all users. --grants-for-all or --grants-for=ALL maybe?

How to repeat:
[13 Jun 2007 9:54] Valeriy Kravchuk
Thank you for a reasonable feature request.
[12 Mar 2010 23:09] Gavin Matthews
This page describes how to roll your own script:
[9 Mar 2013 1:16] Cesar Martins Cesar
I need this too!
This is a basic feature , why missing this for so long ?  
All other databases vendors have at least a easy way to do this...
[16 Nov 2014 11:53] Daniƫl van Eeden
In information_schema there are USER_PRIVILEGES, SCHEMA_PRIVILEGES, COLUMN_PRIVILEGES and TABLE_PRIVILEGES tables available.


The mysqluserclone utility from MySQL Utilities can be used to do dump users with the --dump option.