当前位置:网站首页>Mysqlimport imports data files into the database
Mysqlimport imports data files into the database
2022-07-06 17:44:00 【Oh, no, I forgot my paper】
matters needing attention 1:mysqlimport Import the data file into the corresponding table , Data file type support text,txt,csv, And the number of data file fields must be consistent with the number of table fields , The data file name must be consistent with the table name .
matters needing attention 2: Use mysqlimport It needs to be turned on when mysql Of local_inflie Parameters , by default off.
Opening method 1: Enter the database and execute set global local_infile=1;
Check the status ;
mysql> show global variables like 'local_infile';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | ON |
+---------------+-------+
1 row in set (0.00 sec)
Opening method 2: Edit database profile my.cnf, stay mysqld Add a line below local_infile=ON;
Restart the database to take effect ;
systemctl restart mysqld
[[email protected] ~]# cat fa.txt
3,zhanglei
4,lisi
[[email protected] ~]# mysqlimport -uroot -p --local test fa.txt --fields-terminated-by=','
Enter password:
test.fa: Records: 2 Deleted: 0 Skipped: 0 Warnings: 0
[[email protected] ~]# mysql -uroot -p -e "select * from test.fa;"
Enter password:
+----+----------+
| id | name |
+----+----------+
| 3 | zhanglei |
| 4 | lisi |
+----+----------+
--local test fa.txt test It's the name of the library fa.txt It's the name of the file
--fields-terminated-by=',' Separator ,
In the face of excel File is converted to txt perhaps csv When waiting for format , The encoding format should be UTF-8, The separator is a comma ;txt Wait for the file separator to write by yourself .
边栏推荐
- Automatic operation and maintenance sharp weapon ansible Foundation
- 分布式(一致性协议)之领导人选举( DotNext.Net.Cluster 实现Raft 选举 )
- 06 products and promotion developed by individuals - code statistical tools
- Start job: operation returned an invalid status code 'badrequst' or 'forbidden‘
- 应用服务配置器(定时,数据库备份,文件备份,异地备份)
- Re signal writeup
- 【MySQL入门】第四话 · 和kiko一起探索MySQL中的运算符
- MySQL报错解决
- OpenCV中如何使用滚动条动态调整参数
- Flink analysis (II): analysis of backpressure mechanism
猜你喜欢
Vscode matches and replaces the brackets
Zen integration nails, bugs, needs, etc. are reminded by nails
sql语句优化,order by desc速度优化
10 advanced concepts that must be understood in learning SQL
【ASM】字节码操作 ClassWriter 类介绍与使用
Reppoints: advanced order of deformable convolution
pip install pyodbc : ERROR: Command errored out with exit status 1
Unity particle special effects series - treasure chest of shining stars
[reverse] repair IAT and close ASLR after shelling
FlutterWeb浏览器刷新后无法回退的解决方案
随机推荐
[rapid environment construction] openharmony 10 minute tutorial (cub pie)
Unity tips - draw aiming Center
Debug and run the first xv6 program
中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障
Solrcloud related commands
Sqoop I have everything you want
EasyCVR电子地图中设备播放器loading样式的居中对齐优化
Openharmony developer documentation open source project
Uipath browser performs actions in the new tab
Summary of Android interview questions of Dachang in 2022 (I) (including answers)
The solution to the left-right sliding conflict caused by nesting Baidu MapView in the fragment of viewpager
Debug xv6
Guidelines for preparing for the 2022 soft exam information security engineer exam
07个人研发的产品及推广-人力资源信息管理系统
Concept and basic knowledge of network layering
Compile and build, from the bottom to the top
在一台服务器上部署多个EasyCVR出现报错“Press any to exit”,如何解决?
05 personal R & D products and promotion - data synchronization tool
Wechat applet obtains mobile number
C WinForm series button easy to use