Skip to content

Instantly share code, notes, and snippets.

@wagnerpinheiro
Created April 10, 2014 13:47
Show Gist options
  • Save wagnerpinheiro/10384078 to your computer and use it in GitHub Desktop.
Save wagnerpinheiro/10384078 to your computer and use it in GitHub Desktop.
backup mysql users
mysql -BNe "select concat('\'',user,'\'@\'',host,'\'') from mysql.user where user != 'root'" | \
while read uh; do mysql -BNe "show grants for $uh" | sed 's/$/;/; s/\\\\/\\/g'; done > grants.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment