mysql 导入 文本数据

mysql导入文本步骤 1、修改mysql.ini ,增加配置

[mysqld]
local_infile=ON
[mysql]
local_infile=ON

2、springboot mysql配置增加 allowLoadLocalInfile=true

url: jdbc:mysql://localhost:3306/flowable?allowLoadLocalInfile=true

3、执行SQL

/*controller*/
long start = System.currentTimeMillis();
​
String sql = "load data local infile 'd:/sys_product.txt' into table `sys_product` fields terminated by '\t'";
Map<String,String> map = new HashMap<>();
map.put("sql",sql);
sysProductService.execute(map);
​
long end = System.currentTimeMillis();
return "运行时间(毫秒): = " + (end - start);
​
​
​
/*mapper*/
@Insert("${sql}")
void execute(Map<String, String> map);

 

 
posted @ 2023-01-12 15:44  湖北技升软件  阅读(198)  评论(0)    收藏  举报