Created
April 17, 2019 15:15
-
-
Save cheneyveron/870e6c55221b4ef7240a3e773d917b5c to your computer and use it in GitHub Desktop.
This file contains 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
mysql -u<user> -p<pass> -h<host> -e"select concat('show grants for ','\'',user,'\'@\'',host,'\'') from mysql.user" > user_list_with_header.txt | |
sed '1d' user_list_with_header.txt > ./user.txt | |
while read user; do mysql -u<user> -p<pass> -h<host> -e"$user" > user_grant.txt; sed '1d' user_grant.txt >> user_privileges.txt; echo "flush privileges" >> user_privileges.txt; done < user.txt | |
awk '{print $0";"}' user_privileges.txt >user_privileges_final.sql | |
rm user.txt user_list_with_header.txt user_grant.txt user_privileges.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment