标签:mys ted p12 小型 style nbsp school closed sch
#1. 物理备份: 直接复制数据库文件,适用于大型数据库环境。但不能恢复到异构系统中如Windows。 #2. 逻辑备份: 备份的是建表、建库、插入等操作所执行SQL语句,适用于中小型数据库,效率相对较低。 #3. 导出表: 将表导入到文本文件中。
一、使用mysqldump实现逻辑备份
单库备份:
表的备份:
多库备份:
对所有库的备份:
二、恢复逻辑备份
三,表的导出和导入:
SELECT... INTO OUTFILE 导出文本文件 示例: mysql> SELECT * FROM school.student1 INTO OUTFILE ‘student1.txt‘ FIELDS TERMINATED BY ‘,‘ //定义字段分隔符 OPTIONALLY ENCLOSED BY ‘”‘ //定义字符串使用什么符号括起来 LINES TERMINATED BY ‘\n‘ ; //定义换行符 mysql 命令导出文本文件 示例: # mysql -u root -p123 -e ‘select * from student1.school‘ > /tmp/student1.txt # mysql -u root -p123 --xml -e ‘select * from student1.school‘ > /tmp/student1.xml # mysql -u root -p123 --html -e ‘select * from student1.school‘ > /tmp/student1.html LOAD DATA INFILE 导入文本文件 mysql> DELETE FROM student1; mysql> LOAD DATA INFILE ‘/tmp/student1.txt‘ INTO TABLE school.student1 FIELDS TERMINATED BY ‘,‘ OPTIONALLY ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘\n‘;
标签:mys ted p12 小型 style nbsp school closed sch
原文地址:http://www.cnblogs.com/wxp5257/p/7521571.html