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 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 > sqlusers.sql

{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