mysql dump all users and privileges


Dumping:
mysql --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql --skip-column-names -A | sed 's/$/;/g' > mysql_user_grants.sql

Importing:
mysql mysql < mysql_user_grants.sql mysql -e "flush privileges" -D mysql

Leave a Reply

Your email address will not be published. Required fields are marked *