当前位置:网站首页>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 .
边栏推荐
- Kali2021 installation and basic configuration
- 03个人研发的产品及推广-计划服务配置器V3.0
- Total / statistics function of MySQL
- Pyspark operator processing spatial data full parsing (5): how to use spatial operation interface in pyspark
- 中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障
- 分布式不来点网关都说不过去
- 【MySQL入门】第四话 · 和kiko一起探索MySQL中的运算符
- 【MySQL入门】第三话 · MySQL中常见的数据类型
- Automatic operation and maintenance sharp weapon ansible Playbook
- BearPi-HM_ Nano development environment
猜你喜欢

Reppoints: advanced order of deformable convolution

TCP connection is more than communicating with TCP protocol

03 products and promotion developed by individuals - plan service configurator v3.0

04 products and promotion developed by individuals - data push tool

Kali2021 installation and basic configuration
![[reverse] repair IAT and close ASLR after shelling](/img/83/1c77e24e9430fb7ea775169a794a28.png)
[reverse] repair IAT and close ASLR after shelling

学 SQL 必须了解的 10 个高级概念

07 personal R & D products and promotion - human resources information management system

2022年大厂Android面试题汇总(一)(含答案)

OpenCV中如何使用滚动条动态调整参数
随机推荐
Solution qui ne peut pas être retournée après la mise à jour du navigateur Web flutter
[reverse intermediate] eager to try
Xin'an Second Edition: Chapter 24 industrial control safety demand analysis and safety protection engineering learning notes
[ciscn 2021 South China]rsa writeup
Flink analysis (I): basic concept analysis
Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
Pytorch extract middle layer features?
虚拟机启动提示Probing EDD (edd=off to disable)错误
Spark accumulator and broadcast variables and beginners of sparksql
Virtual machine startup prompt probing EDD (edd=off to disable) error
C#WinForm中的dataGridView滚动条定位
[reverse primary] Unique
Deploy flask project based on LNMP
Total / statistics function of MySQL
Vscode replaces commas, or specific characters with newlines
Hongmeng introduction and development environment construction
MySQL Advanced (index, view, stored procedures, functions, Change password)
connection reset by peer
How to submit data through post
DataGridView scroll bar positioning in C WinForm