赞
踩
1.导出全表数据。
select * from test into outfile '/tmp/a.sql';
2.导出某个数据库下的表。
--secure-file-priv=''
mysqldump -T /data/backup -u root -prootroot --set-gtid-purged=OFF test
将test数据库导出到:backup目录下。
3.导出自定义格式的文件。
mysql -uroot -prootroot -e "select * from t2;" test > t2.sql
id name age
1 NULL 18
2 xsq2 18
3 xsq3 18
4 xsq4 18
5 xsq5 18
4.输出垂直列的结果。
mysql -uroot -prootroot --vertical -e "select * from t2;" test > t2_3.sql
*************************** 1. row ***************************
id: 1
name: NULL
age: 18
*************************** 2. row ***************************
id: 2
name: xsq2
age: 18
5.导出htm格式。
mysql -uroot -prootroot --html -e "select * from t2;" test > t2_4.html
6.导出xml 格式。
mysql -uroot -prootroot --xml -e "select * from t2;" test > t2_5.xml
<?xml version="1.0"?>
<resultset statement="select * from t2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<row>
<field name="id">1</field>
<field name="name" xsi:nil="true" />
<field name="age">18</field>
</row>
<?xml version="1.0"?>
7.生成操作日志:
mysql>tee a.log
mysql>select * from t2;
mysql>notee
8.数据导入。
mysql> load data infile '/data/backup/t2.txt' into table test.t2;
或者:
load data local infile 'data.log' into table data_log field terminated by '|' lines terminated by '\n' (col1,col2,col3);
--将t2表导入test数据库中。
mysqlimport -uroot -prootroot test '/data/backup/t2.txt'
或者:
time mysqlimport -uroot -prootroot test '/data/backup/t2.txt'
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。