Backup and restore mariadb with mysqldump

Backup and restore mariadb using mysqldump

 

1/ Backup​​ single Database

 

shell>​​ mysqldump db_name > backup-file.sql

2/ Restoring or loading the database

 

shell> mysql db_name < backup-file.sql

3/​​ Backup all database

 

mysqldump --all-databases > /opt/alldb.sql

4/ Restore all Database

mysql -u root -p

source /opt/alldb.sql;

Quá trình diễn ra:

.

.

.

Query OK, 0 rows affected (0.056 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 1 row affected (0.000 sec)

 

Database changed

Query OK, 1 row affected (0.000 sec)

 

Database changed

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Database changed

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Database changed

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Database changed

Query OK, 0 rows affected (0.001 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.001 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Database changed

Database changed

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Database changed

Database changed

Database changed

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

 

Query OK, 0 rows affected (0.000 sec)

# kiểm tra lại

 

MariaDB [test005]> show databases;

+--------------------+

| Database  ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ |

+--------------------+

| classicmodels  ​​ ​​ ​​ ​​​​ |

| employees  ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ |

| information_schema |

| mysql  ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ |

| performance_schema |

| test  ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ |

| test001  ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ |

| test002  ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ |

| test003  ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ |

| test005  ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​ ​​​​ |

+--------------------+

10 rows in set (0.000 sec)

Lưu ý:​​ ngoài cách backup trên bạn cũng có thể sử dụng​​ MariaDB​​ Replicate để backup.​​ Nếu note chính bị lỗi thì vẫn còn node slave dự phòng. Sử dụng MariaDB​​ 

 

 

Link tham khảo:

https://mariadb.com/kb/en/library/backup-and-restore-overview/

 

https://mariadb.com/kb/en/replication-as-a-backup-solution/

 

 

chúc các bạn thành công.

BÀI VIẾT CÙNG CHUYÊN MỤC

Hướng dẫn nâng cấp CyberPanel 3.0.6 trên Ubuntu 22.04
Hướng dẫn nâng cấp CyberPanel 3.0.6 trên Ubuntu 22.04

Hướng dẫn nâng cấp CyberPanel 3.0.6 trên Ubuntu 22.04

Kết hợp Let’s Encrypt SSL với Cloudflare Proxy: Mô hình HTTPS an toàn cho website
Kết hợp Let’s Encrypt SSL với Cloudflare Proxy: Mô ...

Kết hợp Let’s Encrypt SSL với Cloudflare Proxy: Mô hình HTTPS an toàn cho ...

Hướng dẫn nâng cấp GitLab EE 19.2.4 lên 19.3.2 an toàn trên Ubuntu 24.04
Hướng dẫn nâng cấp GitLab EE 19.2.4 lên 19.3.2 an toàn ...

Hướng dẫn nâng cấp GitLab EE 19.2.4 lên 19.3.2 an toàn trên Ubuntu 24.04

Mẫu nhúng HTML cho khóa học – Course trên Canvas LMS tại CloudX
Mẫu nhúng HTML cho khóa học – Course trên Canvas LMS ...

Mẫu nhúng HTML cho khóa học – Course trên Canvas LMS tại CloudX

Telegram biến mất khỏi App Store: Người dùng iPhone tải và cài đặt thế nào cho an toàn?
Telegram biến mất khỏi App Store: Người dùng iPhone ...

Telegram biến mất khỏi App Store: Người dùng iPhone tải và cài đặt thế nào cho ...

CẢNH BÁO BẢO MẬT: Lỗ Hổng Nghiêm Trọng CVE-2026-42533 Trên NGINX – Cập Nhật Ngay Để Tránh Rủi Ro Bị Tấn Công
CẢNH BÁO BẢO MẬT: Lỗ Hổng Nghiêm Trọng CVE-2026-42533 ...

CẢNH BÁO BẢO MẬT: Lỗ Hổng Nghiêm Trọng CVE-2026-42533 Trên NGINX – Cập Nhật ...