Have a Question?

Categories

How do I make a backup of the database?

You are here:
< All topics
Table of contents

Almost every modern website uses a MySQL database. More popular content management systems, such as WordPress, Magento, Joomla, store all data in a MySQL database. If, for some reason, we want to back up the database, such as a MySQL server update, then it is possible to extract the data stored in the database or to recover the dump in case of a possible error.

Compress a folder

After you connect to the server via SSH, you can create a backup by issuing the following command:

mysqldump -u user_name -p database_name --single-transaction | gzip -2 > db.sql.gz

By issuing the above command, you create a compressed dump with a single transaction token.

Of course, it is also possible to make an uncompressed dump, but it will take a lot more time and more space will be spent on dumped content.
mysqldump -u user_name -p database_name > db.sql

Extract an archive

You can do this by issuing the following command

gunzip < db.sql.gz | mysql -u user_name -p database_name

To restore an uncompressed database, use the following command:
mysql -u user_name -p database_name < db.sql
Was this article helpful?
0 out Of 5 Stars
5 Értékelés 0%
4 Értékelés 0%
3 Értékelés 0%
2 Értékelés 0%
1 Értékelés 0%
How can we correct this article?
Please submit the reason for your vote so that we can improve the article.
Tags: