当前位置:网站首页>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 .
边栏推荐
- Based on infragistics Document. Excel export table class
- Flink analysis (II): analysis of backpressure mechanism
- Solid principle
- mysql高级(索引,视图,存储过程,函数,修改密码)
- Pytorch extract middle layer features?
- 面试突击63:MySQL 中如何去重?
- C#WinForm中的dataGridView滚动条定位
- 2021-03-22 "display login screen during recovery" can't be canceled. The appearance of lock screen interface leads to the solution that the remotely connected virtual machine can't work normally
- Final review of information and network security (full version)
- Example of batch update statement combining update and inner join in SQL Server
猜你喜欢

Uipath browser performs actions in the new tab

Deploy flask project based on LNMP

Zen integration nails, bugs, needs, etc. are reminded by nails

应用服务配置器(定时,数据库备份,文件备份,异地备份)

Pyspark operator processing spatial data full parsing (5): how to use spatial operation interface in pyspark

基于STM32+华为云IOT设计的智能路灯

03个人研发的产品及推广-计划服务配置器V3.0
![[reverse intermediate] eager to try](/img/5a/568533850ddfd1c41117da0df50e20.png)
[reverse intermediate] eager to try
![[getting started with MySQL] fourth, explore operators in MySQL with Kiko](/img/11/66b4908ed8f253d599942f35bde96a.png)
[getting started with MySQL] fourth, explore operators in MySQL with Kiko

05 personal R & D products and promotion - data synchronization tool
随机推荐
RepPoints:可形变卷积的进阶
面试突击63:MySQL 中如何去重?
How uipath determines that an object is null
Grafana 9 is officially released, which is easier to use and more cool!
FlutterWeb瀏覽器刷新後無法回退的解决方案
Based on infragistics Document. Excel export table class
Unity particle special effects series - treasure chest of shining stars
全网最全tcpdump和Wireshark抓包实践
Solr appears write Lock, solrexception: could not get leader props in the log
应用服务配置器(定时,数据库备份,文件备份,异地备份)
[introduction to MySQL] third, common data types in MySQL
Solrcloud related commands
PyTorch 提取中间层特征?
Binary search strategy
The art of Engineering (1): try to package things that do not need to be exposed
Basic configuration and use of spark
远程代码执行渗透测试——B模块测试
Unity tips - draw aiming Center
SAP UI5 框架的 manifest.json
Example of batch update statement combining update and inner join in SQL Server