Created
February 12, 2015 16:04
-
-
Save pstaender/f255ba2caa1b914979d7 to your computer and use it in GitHub Desktop.
Dump MySQL Privileges to import in an existing / other database
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
| #!/bin/sh | |
| # from https://saiyedfaishal.wordpress.com/2014/03/20/exporting-all-mysql-user-privileges/ | |
| HOST="127.0.0.1";USER="root";PASSWORD="root";mysql -h $HOST -u $USER -p$PASSWORD -Ne "select distinct concat( \"SHOW GRANTS FOR '\",user,\"'@'\",host,\"';\" ) from user;" mysql | mysql -h $HOST -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