Skip to content

Instantly share code, notes, and snippets.

@nikolazic
Created March 17, 2015 20:52
Show Gist options
  • Save nikolazic/b0977c3b598b26fb86c8 to your computer and use it in GitHub Desktop.
Save nikolazic/b0977c3b598b26fb86c8 to your computer and use it in GitHub Desktop.
Get all users' grants
sudo mysql --silent --skip-column-names --execute "select concat('\'',User,'\'@\'',Host,'\'') as User from mysql.user" | sort | \
while read u
do echo "-- $u"; sudo mysql --silent --skip-column-names --execute "show grants for $u" | sed 's/$/;/'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment