Skip to content

Instantly share code, notes, and snippets.

@noelrocha
Created December 19, 2011 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noelrocha/1499300 to your computer and use it in GitHub Desktop.
Save noelrocha/1499300 to your computer and use it in GitHub Desktop.
export MYSQL privileges
mysql -u [USER] -p[PASSWORD] -B -N $@ -e "SELECT DISTINCT CONCAT(
'SHOW GRANTS FOR ''', user, '''@''', host, ''';'
) AS query FROM mysql.user" | \
mysql -u [USER] -p[PASSWORD] $@ | \
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