mysqldump

MySQL: bash script to dump all users

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:

 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.

Leave a Comment

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

Scroll to Top