User Tools

Site Tools


mysql:export_users_with_grants

This is an old revision of the document!


MySQL - Export users with grants

Run this query:

### mysql -uroot -p{PASS} -B -N -e "SELECT DISTINCT CONCAT('SHOW GRANTS FOR \'', user, '\'@\'', host, '\';') AS query FROM mysql.user" | mysql -uroot -p{PASS} | sed 's/\(GRANT .\)/\1;/;s/^\(Grants for .\)/## \1 ##/;/##/{x;p;x;}'
mysql/export_users_with_grants.1467591008.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki