数据备份和还原

-- 单表数据备份

select *  into outfile 'C:/Users/78/Desktop/web/web2/web/student.txt' from my_student;

select *  into outfile 'C:/Users/78/Desktop/web/web2/web/class.txt' from my_class;

-- 指定备份处理方式

select * into outfile 'C:/Users/78/Desktop/web/web2/web/class1.txt'

fields

enclosed by '"' -- 数据使用双引号包裹

terminated by '|' -- 使用竖线分隔字段数据

-- 行处理

lines

starting by 'select:'

from my_class;

-- 还原数据

load data infile 'C:/Users/78/Desktop/web/web2/web/class1.txt' into table my_classfields enclosed by '"' terminated by

'|' lines starting by 'START';

select * from my_class;

-- sql备份

mysqldump -uroot -proot mybd my_student > C:/Users/78/Desktop/web/web2/web/student.sql

-- 整库备份

mysqldump -uroot -proot mybd > C:/Users/78/Desktop/web/web2/web/mybd.sql

-- sql 还原

drop table my_student;

show tables ;

\q

-- 还原数据:mysql客户端还原

mysql -uroot -proot mybd < C:/Users/78/Desktop/web/web2/web/mybd.sql;

select * from my_student;

drop table my_student; -- 删除学生表

-- sql指令还原sql备份

source C:/Users/78/Desktop/web/web2/web/mybd.sql;

select  * from my_student;

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容