当前位置:网站首页>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 .
边栏推荐
- Debug and run the first xv6 program
- Flexible report v1.0 (simple version)
- C#WinForm中的dataGridView滚动条定位
- Guidelines for preparing for the 2022 soft exam information security engineer exam
- The solution that flutterweb browser cannot be rolled back after refreshing
- PySpark算子处理空间数据全解析(5): 如何在PySpark里面使用空间运算接口
- 遠程代碼執行滲透測試——B模塊測試
- Quick start of Hongmeng system
- How to submit data through post
- [getting started with MySQL] fourth, explore operators in MySQL with Kiko
猜你喜欢
BearPi-HM_ Nano development board "flower protector" case
05 personal R & D products and promotion - data synchronization tool
[elastic] elastic lacks xpack and cannot create template unknown setting index lifecycle. name index. lifecycle. rollover_ alias
Flink parsing (IV): recovery mechanism
C# NanoFramework 点灯和按键 之 ESP32
06个人研发的产品及推广-代码统计工具
Yarn: unable to load file d:\programfiles\nodejs\yarn PS1, because running scripts is prohibited on this system
Optimization of middle alignment of loading style of device player in easycvr electronic map
[reverse intermediate] eager to try
【MySQL入门】第一话 · 初入“数据库”大陆
随机推荐
中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障
Concept and basic knowledge of network layering
BearPi-HM_ Nano development environment
Vscode matches and replaces the brackets
Xin'an Second Edition; Chapter 11 learning notes on the principle and application of network physical isolation technology
Xin'an Second Edition: Chapter 24 industrial control safety demand analysis and safety protection engineering learning notes
Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
Unity tips - draw aiming Center
全网最全tcpdump和Wireshark抓包实践
The solution that flutterweb browser cannot be rolled back after refreshing
PySpark算子处理空间数据全解析(5): 如何在PySpark里面使用空间运算接口
04 products and promotion developed by individuals - data push tool
Pyspark operator processing spatial data full parsing (5): how to use spatial operation interface in pyspark
Yarn: unable to load file d:\programfiles\nodejs\yarn PS1, because running scripts is prohibited on this system
Final review of information and network security (based on the key points given by the teacher)
yarn : 无法加载文件 D:\ProgramFiles\nodejs\yarn.ps1,因为在此系统上禁止运行脚本
mysql高級(索引,視圖,存儲過程,函數,修改密碼)
RepPoints:可形变卷积的进阶
分布式(一致性协议)之领导人选举( DotNext.Net.Cluster 实现Raft 选举 )
Flexible report v1.0 (simple version)