O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Backup users

In mysqldump, you will not get a backup of the users in CREATE USER or GRANT statements; instead you have to take a backup of the mysql.user table. Using mysqlpump, you can dump user accounts as account management statements (CREATE USER and GRANT) rather than as inserts into the mysql system database:

shell> mysqlpump --exclude-databases=% --users > users_backup.sql

You can also exclude some users by specifying the --exclude-users option:

shell> mysqlpump --exclude-databases=% --exclude-users=root --users > users_backup.sql

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required