数据备份与恢复

数据备份  方法1

select * from  mysql_test.customers                 查表

into outfile   'C:/BACKUP/bcakupfile.txt'             备份目录,注意提前建BACKUP目录,备份的文件一定要跟数据库同一目录

fields  terminated by  ','                                           字段值之间用逗号

optionally  enclosed by ""                                         字段值有字符用双引号

lines terminated by  '?'  ;                                           每行结束用问号

数据备份  方法2

select  *  into  outfile  'C:/customers.txt'   from  customers   

数据恢复

前提是建立一张空表,属性顺序要一直,主要类型一直,否则容易报错。

load data infile  'C:/BACKUP/backupfile.txt'

into table mysql_test.customers_copy

fields   terminated by  ','

optionally  enclosed by  ""

lines   terminated by  '?';

你可能感兴趣的:(数据备份与恢复)