首页 > 解决方案 > 如何将具有 188 万行的 .csv 文件中的数据导入 MySQL

问题描述

我正在尝试将以下链接中的数据加载到 MYSQL 数据库方案中

点击这里

但它在 30 秒后超时

我已经使用代码将时间设置为 1000 秒。但它仍然不起作用

 show variables like "net_read_timeout"

set net_read_timeout = 1000; 

我应该如何将 188 万行加载到我的架构中

标签: mysqlsql

解决方案


LOAD DATA INFILE is your solution. You can read the documentation from the MySQL website and generate the LOAD DATA query for your need. Make sure you put the file in a place where MySQL process can read. It can only load files from certain location. Again it is part of the documentation.

https://dev.mysql.com/doc/refman/8.0/en/load-data.html

LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test FIELDS TERMINATED BY ',' LINES STARTING BY 'xxx';


推荐阅读