If you need to dump all mysql users created on your linux machine you can do it quite easy, using a simple bash script.
Create a new bash script as follows:
1 2 3 4 | root@zira # cat > dump_sqlusers.sh #!/bin/bash SQL_CONN="-u{user} -p{password}" mysql ${SQL_CONN} --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql ${SQL_CONN} --skip-column-names -A | sed 's/$/;/g' |
Save the file, chmod +x dump_sqlusers.sh. Then just execute the script! It will dump all your users right on the screen. If you want to save that to a file, you can just execute the script and redirect the output to a file like this:
root@zira# sh dump_sqlusers.sh > sqlusers.sql
NOTE:
{user} = your root mysql user, or a mysql user that has full rights
{password} = the password of that user
Obviously, this script exports only the users and their permissions, the passwords are encrypted and you have to know them.