Backup và Restore MySQL Database bằng lệnh (Command)

TricksMMO

Administrator
Staff member
|gzip> [bk.sql.gz] ** Cách sao lưu cơ sở dữ liệu MySQL với lệnh trong Terminal **

Sao lưu dữ liệu là một phần không thể thiếu của quản trị viên cơ sở dữ liệu.Do đó, cơ sở dữ liệu sao lưu (sao lưu) MySQL thường cần thiết.Hầu hết các bạn thường sử dụng phpmyadmin để sao lưu hoặc khôi phục.

Bạn có thể đơn giản hóa bằng cách sử dụng lệnh trong thiết bị đầu cuối để sao lưu và khôi phục, theo các hướng dẫn dưới đây:

Ghi chú chung trong các tuyên bố:

* [Uname]: Cơ sở dữ liệu người dùng
* [Dbname]: tên cơ sở dữ liệu
* [BK.SQL]: Tên tệp sao lưu sẽ được tạo
* [---OPT]: Thêm các tùy chọn của lệnh

1. Sao lưu với lệnh trong thiết bị đầu cuối (sao lưu)

Sử dụng cấu trúc như sau:

`` `
$ mysqldump --opt -u [uname] -p [dbname]> [bk.sql]
`` `

Ví dụ: cơ sở dữ liệu dự phòng Duyquangnet

`` `
$ mysqldump -u root -p Duyquangnet> bk_duyquangnet.sql
`` `

Bạn cũng có thể phụ thuộc vào bản sao lưu riêng biệt theo bảng bằng cách chọn bảng cần sao lưu theo thứ tự dưới đây:

`` `
$ mysqldump -u root -p Duyquangnet TAGE_A TAGE_B> BK_DUYQUANGNET.SQL
`` `

Sao lưu cơ sở dữ liệu MySQL tự động nén

Nếu cơ sở dữ liệu của bạn quá lớn, bạn có thể tự động nén để giảm công suất, chúng tôi có thể sử dụng cấu trúc lệnh nén với gzip

`` `
$ mysqldump -u [uname] -p [dbname] |gzip> [bk.sql.gz]
`` `
=======================================
| gzip > [BK.SQL.gz] **How to backup MySQL database with command in Terminal**

Data backup is an integral part of the database administrator. Therefore, Backup (backup) MySQL Database is often necessary. Most of you often use phpmyadmin to backup or restore.

You can simplify by using the command in Terminal to backup and restore, according to the instructions below:

General notes in the statements:

* [UNAME]: User Database
* [DBNAME]: Database name
* [BK.SQL]: Backup file name will be created
* [--opt]: Add options of the command

1. Backup with command in Terminal (backup)

Use the structure as follows:

```
$ mysqldump --opt -u [uname] -p [dbname]> [BK.SQL]
```

For example: to backup database duyquangnet

```
$ mysqldump -u root -p Duyquangnet> bk_duyquangnet.sql
```

You can also depend on the separate backup by the table by selecting the table that needs backup according to the order below:

```
$ mysqldump -u root -p Duyquangnet Table_A Table_B> bk_duyquangnet.sql
```

Back up mysql database automatically compressed

If your database is too large, you can automatically compress to reduce the capacity, we can use the compressed command structure with Gzip

```
$ mysqldump -u [uname] -p [dbname] | gzip > [BK.SQL.gz]
```
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top