当前位置:网站首页>将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开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- I met a shell script
- 力扣(LeetCode)212. 单词搜索 II(2022.07.31)
- DL-31/6电流继电器
- LeetCode 1189. “气球” 的最大数量
- Selenium: Manipulating Cookies
- The method of solving stored procedure table name passing through variable in mysql
- pytorch、tensorflow对比学习—张量
- Excuse me, only primary key columns can be queried using sql in table storage. Does ots sql not support non-primary keys?
- 4D line-by-line analysis and implementation of Transformer, and German translation into English (3)
- (2022 Niu Ke Duo School IV) N-Particle Arts (Thinking)
猜你喜欢

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

typescript23-元组

Dry goods!How to Construct SRv6-TE Performance Test Environment Using Instrumentation

56:第五章:开发admin管理服务:9:开发【文件上传到,MongoDB的GridFS中,接口】;(把文件上传到GridFS的SOP)

可视化全链路日志追踪

(Codeforce 757) E. Bash Plays with Functions

typescript23-tuple

(more than 2022 cattle school four) A - Task Computing + dynamic programming (sort)

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

Excel record of integer programming optimization model to solve the problem
随机推荐
Lawyer Interpretation | Guns or Roses?Talking about Metaverse Interoperability from the Battle of Big Manufacturers
y83. Chapter 4 Prometheus Factory Monitoring System and Actual Combat -- Advanced Prometheus Alarm Mechanism (14)
Typescript22 - interface inheritance
Selenium:元素等待
Code Interview Guide for Programmers CD15 Generating an Array of Windowed Maximums
typescript28-枚举类型的值以及数据枚举
pytorch、tensorflow对比学习—功能组件(激活函数、模型层、损失函数)
scheduleWithFixedDelay和scheduleAtFixedRate的区别
pytorch、tensorflow对比学习—张量
pytroch、tensorflow对比学习—功能组件(数据管道、回调函数、特征列处理)
I met a shell script
【MySQL必知必会】 表的优化 | 充分利用系统资源
typescript26 - literal types
pytroch、tensorflow对比学习—搭建模型范式(构建模型方法、训练模型范式)
Error: AttributeError: module 'matplotlib' has no attribute 'figure'
2022年超全的Android面经(附含面试题|进阶资料)
Use controls as brushes to get bitmap code records
pytroch、tensorflow对比学习—使用GPU训练模型
Selenium: browser operation
pytroch、tensorflow对比学习—搭建模型范式(低阶、中阶、高阶API示例)