从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
posted @ 2023-07-10 08:57  哈喽哈喽111111  阅读(175)  评论(0编辑  收藏  举报