MariaDB restore database from backup - mysql
Colleagues hello to all.
In today's article, we'll talk about how to restore a database from a backup in MariaDB. Backups were created using the mysqldump utility. We will restore the database using the built-in mysql utility.
Related articles:
Article content:
- Restore a normal copy using the mysql utility.
- Restore a compressed copy using the mysql utility.
1. Restore a regular backup using the mysql utility.
In previous articles, we performed backups using the mysqldump utility. An example from a previous article creating a full database backup.
$. mysqldump -u root -p --all-databases --result-file=/app/mariadb_backup/dump.sql
Now, in order to restore this backup, we all just need to perform one simple action:
$. mysql -u root -p < dump.sql
After executing the specified command, our database will be completely restored at the time the backup was created.
2. Restore a compressed copy using the mysql utility.
In one of the examples in the last article, we performed a full database backup, but only used the compression process with the bzip2 utility to make the backup take up less disk space. An example from the last article of a full backup.
$. mysqldump -u root -p --all-databases | bzip2 > /app/mariadb_backup/dump.sql.bz2
Now, in order to restore this backup, we need to run a simple command:
$. bzcat dump.sql.bz2 | mysql -u root -p
After executing the specified command, our database will be completely restored at the time the backup was created.
Thank you all, I hope that my article helped you in some way.