从mysql中把查询结果导出为txt文件,把txt文件导入到mysql数据库中
- 从mysql中把查询结果导出为txt文件
#!/bin/bash
echo "
set names utf8;
use mall_test;
select phone,gender from unimall_user where id<=120466;
"|mysql -hx.x.x.x -P3306 -uxxx -pxxx > test.txt
- 把txt文件导入到mysql数据库中
#!/bin/bash
echo "
set names utf8;
use mall_test;
load data local infile 'test.txt' ignore into table
test_ce ignore 1 lines (user_name,sex);
"|mysql -hx.x.x.x -P3306 -uxxx -pxxx