当前位置:网站首页>将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开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- Selenium: element positioning
- 类神经网络训练不起来怎么办
- Li Chi's work and life summary in July 2022
- 4D line-by-line analysis and implementation of Transformer, and German translation into English (3)
- 剑指 Offer 68 - I. 二叉搜索树的最近公共祖先
- Immutable
- 微信小程序获取手机号phonenumber.getPhoneNumber接口开发
- Use controls as brushes to get bitmap code records
- Code Interview Guide for Programmers CD15 Generating an Array of Windowed Maximums
- Selenium: Element wait
猜你喜欢

Robot_Framework:常用内置关键字

Swastika line-by-line parsing and realization of the Transformer, and German translation practice (a)

PaddleX部署推理模型和GUI界面测试结果不一致的解决方法

API Design Notes: The pimpl trick

剑指 Offer 68 - I. 二叉搜索树的最近公共祖先

(2022 Niu Ke Duo School IV) K-NIO's Sword (Thinking)

【目标检测】YOLOv7理论简介+实践测试

UE4 模型OnClick事件不生效的两种原因

PAT serie b write the number 1002

MySQL-数据定义语言-DDLdatebase define language
随机推荐
(2022牛客多校四)A-Task Computing (排序+动态规划)
(more than 2022 cattle school four) A - Task Computing + dynamic programming (sort)
Selenium:表单切换
状态压缩dp
[MySQL] 多表查询
挑战52天背完小猪佩奇(第01天)
NDK does not contain any platforms问题解决
JWL-11/2-99.9A电流继电器
中国的机器人增长
The sword refers to Offer 68 - I. Nearest Common Ancestor of Binary Search Trees
typescript24-类型推论
移动应用恶意攻击激增500% 三六零天御为APP免费构建安全屏障
scheduleWithFixedDelay和scheduleAtFixedRate的区别
MySQL-数据定义语言-DDLdatebase define language
万字逐行解析与实现Transformer,并进行德译英实战(三)
Excuse me, only primary key columns can be queried using sql in table storage. Does ots sql not support non-primary keys?
报错:AttributeError: module ‘matplotlib’ has no attribute ‘figure’
II. Binary tree to Offer 68 - recent common ancestor
Selenium: form switching
Pyspark Machine Learning: Vectors and Common Operations