---
title: "Database Install - Chỉ khôi phục database"
url: https://phatdev.net/docs/sl-migrations/database-install
lang: vi
updated: 2026-10-16
alternate:
  en: https://phatdev.net/en/docs/sl-migrations/database-install
markdown: https://phatdev.net/docs/sl-migrations/database-install.md
---

# Database Install - Chỉ khôi phục database

Thuộc bộ tài liệu: [SL Migrations](https://phatdev.net/docs/sl-migrations.md)

> Restore chỉ database từ backup, giữ nguyên file site hiện tại.

## Database Install

Khi chỉ muốn khôi phục database mà giữ nguyên file (vì file đã đồng bộ qua rsync, git, hoặc một cách khác).

## Kịch bản phổ biến

- Database hiện tại bị corrupt nhưng file vẫn ổn
- Đã rsync file từ staging về production, chỉ cần đồng bộ database
- Test data migration mà không muốn ảnh hưởng file

## Cách làm

### 1. Backup DB hiện tại

Tạo bản sao DB hiện tại trước khi ghi đè. Đa số hosting có công cụ này trong cPanel/Plesk, hoặc dùng `mysqldump` nếu có SSH.

### 2. Upload installer + archive

Upload vào thư mục `wp-content/backups-slm/` của site đang chạy.

### 3. Chạy installer ở mode "Database Only"

Mở `installer.php` trên trình duyệt. Ở bước 1, chọn **Install Database Only** trong dropdown deployment mode.

Installer sẽ skip bước giải nén file, chỉ chạy:
- Drop existing tables
- Import SQL dump
- Search & replace URL

### 4. Verify

- Đăng nhập wp-admin
- Kiểm tra Posts, Settings, Options
- Danh sách Plugin/Theme vẫn nguyên (file không bị động đến)

## Cảnh báo

- **Plugin version mismatch**: Nếu plugin version trong database khác với version file trên site → có thể gây lỗi. Backup plugin trước.
- **Custom tables**: SQL dump chỉ chứa table có prefix theo `table_prefix` trong `wp-config.php`. Custom tables ngoài prefix sẽ KHÔNG được dump.

## Tham khảo

- [Khắc phục lỗi database write](https://phatdev.net/docs/sl-migrations/how-to-fix-database-write-issues)
- [Classic Install](https://phatdev.net/docs/sl-migrations/classic-install)
