How to back up MySQL or MariaDB database

Home > Search > How-to

The mysqldump command can be used to backup one or more MySQL or MariaDB databases.

To backup a single database:

~]# mysqldump -uMyUsername -pMyPassword database_name > /path/to/directory/backup.sql


The --all-databases option can be used to backup every database.

~]# mysqldump -uMyUsername -pMyPassword --all-databases > /path/to/directory/backup.sql


The backup.sql file will contain all of the commands that are needed to recreate the tables in the database, and to insert all of the data into the tables.

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.