Created
January 6, 2013 08:06
-
-
Save morhekil/4465971 to your computer and use it in GitHub Desktop.
shell script to dump existing MySQL privileges as GRANT commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
mysql -B -N $@ -e "SELECT DISTINCT CONCAT( | |
'SHOW GRANTS FOR ''', user, '''@''', host, ''';' | |
) AS query FROM mysql.user" | \ | |
mysql $@ | \ | |
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment