Home Linux ServerWeb Server Command to backup and restore MySQL on Linux

Command to backup and restore MySQL on Linux

by Thạch Phạm

Sometimes you need to import files up to a few hundred MB that you use the interface to export/import will take time and the operation is easy to fail, then you should use Linux’s cmd to process it quickly and safely. To do this, you can follow the steps below.

First, you need to log in to Linux VPS via SSH protocol. Then use the corresponding commands as below to backup and restore the database.

The mysqldump command to backup the database

To back up the database, you need to have all the database information to be backed up, including the user, database name, and password of the database.

Once you have all the information, run the command:

mysqldump --opt -u admin_azdigi -p admin_azdigi > tenfilemoi.sql

In there:

  • admin_azdigi : User of the database
  • admin_azdigi : Database name
  • tenfilemoi.sql : File name to save, this file must have the extension.sql .
  • –opt : mysqldump options

The mysql command to restore the database

To restore the database, you need to create a new database including a user database, database name, and password.

Once you have all the information, run the command:

mysql -u admin_azdigi1 -p admin_azdigi1 < tenfile.sql

In there:

  • admin_azdigi1 : User of the database
  • admin_azdigi1 : Database name
  • tenfile.sql : The path to the .sql file is to be restored.

Wishing you success!

Đánh giá

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign