当前位置:网站首页>将CSV文件快速导入MySQL中
将CSV文件快速导入MySQL中
2022-08-01 05:11:00 【万里长江雪】
一般来说,将csv文件导入mysql数据库有两种办法:
- 使用navicat、workbench等软件中的导入向导手动导入
- 使用load data infile命令导入
前者速度较慢,适合数据量比较小的时候,而对于大文件,我们需要使用命令行导入。
准备工作
在mysql中将表结构先建好,包括字段名及类型等
使用如下命令查看是否允许从外部路径导入文件
show variables like ‘%secure%’;
如果结果显示secure_file_priv=‘’,即空字符串,则无需改动;如果secure_file_priv=null,则需要在mysql的配置文件my.ini中添加如下行secure_file_priv=‘’,之后重启mysql服务。
使用如下命令查看是否允许本地导入
show variables like ‘local_infile’;
如果结果是off,则改使用如下命令改为on
set global local_infile=on;
导入文件
使用如下命令导入文件
注意:文件路径不能有中文!!
load data local infile 'file_path' # 文件路径
into table daily_price # 表名
character set utf8 # 编码
fields terminated by ',' # 分隔符
lines terminated by '
' # 换行符,windows下是
ignore 1 lines; # 忽略第一行,因为表头已建好
其他有关load data infile的细节可在此地址查询
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- pytroch、tensorflow对比学习—搭建模型范式(构建模型方法、训练模型范式)
- pytroch、tensorflow对比学习—功能组件(数据管道、回调函数、特征列处理)
- Risk strategy important steps of tuning method
- typescript27-枚举类型呢
- 冲刺金九银十,Android开发面试(内含面试资料|面试题|源码)
- 混合型界面:对话式UI的未来
- USB3.0:VL817Q7-C0的LAYOUT指南(三)
- (2022牛客多校四)D-Jobs (Easy Version)(三维前缀或)
- 剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
- typescript24 - type inference
猜你喜欢
![[target detection] YOLOv7 theoretical introduction + practical test](/img/ff/a83acbf9dd5cc2f907f3538d287842.png)
[target detection] YOLOv7 theoretical introduction + practical test

Lawyer Interpretation | Guns or Roses?Talking about Metaverse Interoperability from the Battle of Big Manufacturers

律师解读 | 枪炮还是玫瑰?从大厂之争谈元宇宙互操作性

typescript23-tuple

(Codeforce 757) E. Bash Plays with Functions

程序员代码面试指南 CD15 生成窗口最大值数组

Logitech Mouse Experience Record

备战金九银十,如何顺利通过互联网大厂Android的笔面试?

API Design Notes: The pimpl trick

MySQL-数据操作-分组查询-连接查询-子查询-分页查询-联合查询
随机推荐
In the shake database, I want to synchronize the data of the source db0 to the destination db5, how to set the parameters?
Robot_Framework:断言
Typescript22 - interface inheritance
Selenium:元素定位
pytroch、tensorflow对比学习—专栏介绍
Swastika line-by-line parsing and realization of the Transformer, and German translation practice (a)
JWL-11/2-99.9A电流继电器
pytorch、tensorflow对比学习—张量
y83. Chapter 4 Prometheus Factory Monitoring System and Actual Combat -- Advanced Prometheus Alarm Mechanism (14)
typescript21-接口和类型别名的对比
25. Have you been asked these three common interview questions?
PAT乙级 1002 写出这个数
Robot_Framework: commonly used built-in keywords
The method of solving stored procedure table name passing through variable in mysql
Asynchronous reading and writing of files
Excel record of integer programming optimization model to solve the problem
[MySQL] 多表查询
Selenium:元素判断
(Codeforce 757)E. Bash Plays with Functions(积性函数)
混合型界面:对话式UI的未来