当前位置:网站首页>将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开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- typescript28-枚举类型的值以及数据枚举
- pytroch、tensorflow对比学习—搭建模型范式(构建模型方法、训练模型范式)
- MySQL Practice Summary -
- UE4 模型OnClick事件不生效的两种原因
- Logitech Mouse Experience Record
- Swastika line-by-line parsing and realization of the Transformer, and German translation practice (a)
- Selenium: Element wait
- 请问shake数据库中为什么读取100个collection 后,直接就退出了,不继续读了呢?
- 微信小程序用户登录auth.code2Session接口开发
- Selenium:上传、下载文件
猜你喜欢
罗技鼠标体验记录
typescript27 - what about enumeration types
UE4 rays flashed from mouse position detection
The sword refers to Offer 68 - I. Nearest Common Ancestor of Binary Search Trees
Check控件
NDK does not contain any platforms问题解决
SL-12/2过流继电器
The solution to the inconsistency between the PaddleX deployment inference model and the GUI interface test results
剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
Selenium: Popup Handling
随机推荐
Selenium: browser operation
(more than 2022 cattle school four) A - Task Computing + dynamic programming (sort)
Selenium: mouse, keyboard events
Excel record of integer programming optimization model to solve the problem
剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
[MySQL] 多表查询
剑指 Offer 68 - II. 二叉树的最近公共祖先
(2022牛客多校四)K-NIO‘s Sword(思维)
II. Binary tree to Offer 68 - recent common ancestor
挑战52天背完小猪佩奇(第01天)
万字逐行解析与实现Transformer,并进行德译英实战(一)
y83. Chapter 4 Prometheus Factory Monitoring System and Actual Combat -- Advanced Prometheus Alarm Mechanism (14)
Selenium:简介
25. Have you been asked these three common interview questions?
(2022牛客多校四)N-Particle Arts(思维)
(2022 Nioke Duo School IV) D-Jobs (Easy Version) (3D prefix or)
The method of solving stored procedure table name passing through variable in mysql
PAT乙级 1001 害死人不偿命的(3n+1)猜想
Selenium:下拉框操作
ModuleNotFoundError: No module named 'tensorflow.keras' error message solution