สำรองฐานข้อมูลเดี่ยวลงไฟล์ .sql
ใช้ mysqldump สำรองฐานข้อมูลเดียวได้ง่ายๆ
ตัวอย่าง
สำรองฐานข้อมูล tutorials ลงไฟล์ tutorials.sql:
C:\mysql\bin> mysqldump -u root tutorials > tutorials.sql
คำสั่งนี้สร้างไฟล์ tutorials.sql ในโฟลเดอร์ bin ของ MySQL ไฟล์นี้จะมีคำสั่ง DROP TABLE, CREATE TABLE และ INSERT สำหรับทุกตารางในฐานข้อมูล tutorials
ตัวอย่างเนื้อหาไฟล์ (บางส่วนของตาราง rtgs):
-- Table structure for table `rtgs` DROP TABLE IF EXISTS `rtgs`; CREATE TABLE `rtgs` ( `id` int(11) DEFAULT NULL, `name` varchar(20) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- Dumping data for table `rtgs` LOCK TABLES `rtgs` WRITE; INSERT INTO `rtgs` VALUES (1,'Ram'),(2,'Shyam'); UNLOCK TABLES;