数据库的备份、还原
1、备份:在MySQL下进行
mysqldump -h localhost -u root -p123456 wjn>/root/wjn.sql;root----------------用户名
123456--------------密码
wjn-----------------需要备份的数据库名
/root/wjn.sql-------备份文件的位置
2、还原:在MySQL下进行
source /root/wjn.sql/root/wjn.sql-------要还原文件的位置
导出数据:
1、创建一个目录(/root/2018),将目录属主属组更改为MySQL
(1)更改属主 chown -R mysql /root/2018(2)更改属组 chgrp -R mysql /root/2018
(3)在MySQL下进行:
select * from wjn.t1 INTO OUTFILE '/root/2018/1.txt'fields terminated by ',' lines terminated by '\n';
wjn---------数据库名t1---------表格名
/2018/1.txt-------存储的文件位置(1.txt自动创建)
导入数据
(1)创建一个表格(wjn.t1),字段和导入数据字段相同在MySQL下进行
load data local infile '/root/2018/1.txt' into table wjn.t1 fields terminated by ',' lines terminated by '\n';