mysql 数据导入导出

mysql 如何导入txt

mysql 远程执行

mysql -hwww.xxx.com -uroot -p -e 'select * from detail_kd' > /tmp/detail_kd.txt

mysql 输出的数据为

+--------------------+----------+----------+----------------+-----------+-------------+---------------+
| detail_integral_id | user_id  | integral | total_integral | target_id | target_type | create_time   |
+--------------------+----------+----------+----------------+-----------+-------------+---------------+
|           74618432 | 12963299 |       30 |       11991729 |         0 | room        | 1533163756829 |
|           74619240 | 12963299 |      210 |       11991939 |         0 | room        | 1533165021613 |
+--------------------+----------+----------+----------------+-----------+-------------+---------------+

导入sql语句

load data infile '/tmp/detail_kd.txt' into table detail_kd fields terminated by '\t';

infile 后面是导入txt的路径, into table detail_kd kd详情表 terminated byb '\t' 分隔符号

mysqldump导入导出

--where 可以指定过滤条件

mysqldump -uroot -p test detail_integral --where="integral > 330 and user_id > 1" > /tmp/detail_kd.sql
source /tmp/detail_kd.sql

0 comments

To reply to the article, please Login or registered