Created
November 25, 2014 20:53
-
-
Save inxilpro/8f72001f82672727df7c to your computer and use it in GitHub Desktop.
Export all MySQL user permissions
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
| read -s -p "Enter MySQL password for root: " root_password | |
| root_password=$(printf '%q' $root_password) | |
| grants_command='SELECT DISTINCT CONCAT("SHOW GRANTS FOR `", user, "`@`", host, "`;") AS "query" FROM `mysql`.`user`;' | |
| grants=$(mysql -N -s --user=root --password=$root_password --execute="$grants_command") | |
| mysql -N -s -r --user=root --password=$root_password --execute="$grants" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment