Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> MySQL

mysqldump - โปรแกรมสำรองข้อมูล MySQL Database

mysqldump ทำ Logical Backup สร้าง SQL Statements เพื่อ Reproduce Database Objects และ Table Data

การใช้งาน

  • Dump 1+ Databases สำหรับ Backup หรือ Transfer ไป SQL Server อื่น
  • Output: CSV, Delimited Text, XML
  • ต้องการ Privileges: SELECT, SHOW VIEW, TRIGGER, LOCK TABLES (ถ้าไม่ใช้ --single-transaction), PROCESS (ถ้าไม่ใช้ --no-tablespaces)
  • Clone Database สำหรับ Dev/DBA หรือสร้าง Variation สำหรับ Testing

Large-Scale Backup

แนะนำ Physical Backup (Copy Data Files) เร็วกว่า

  • InnoDB หลัก -> ใช้ mysqlbackup (MySQL Enterprise Backup) ประสิทธิภาพดีที่สุด, Disruption น้อยที่สุด

โหมดการดึงข้อมูล

  • Row-by-row
  • Buffer ทั้งตารางใน Memory ก่อน Dump

ไวยากรณ์ 3 รูปแบบ

# 1. Dump Tables
shell> mysqldump [options] db_name [tbl_name ...]

# 2. Dump Databases
shell> mysqldump [options] --databases db_name ...

# 3. Dump Entire Server
shell> mysqldump [options] --all-databases

Dump ทั้ง Database -> ไม่ระบุ Table หรือใช้ --databases/--all-databases