Created
March 19, 2013 14:30
-
-
Save epleterte/5196601 to your computer and use it in GitHub Desktop.
mygrants!
This file contains hidden or 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
# cool mysql grants printing function (producing proper sql) - http://serverfault.com/a/13050 | |
# example: | |
# mygrants --host=prod-db1 --user=admin --password=secret | grep rails_admin | mysql --host=staging-db1 --user=admin --password=secret | |
mygrants() | |
{ | |
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