当前位置:网站首页>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 .
边栏推荐
- Solution qui ne peut pas être retournée après la mise à jour du navigateur Web flutter
- How to use scroll bars to dynamically adjust parameters in opencv
- 自动化运维利器ansible基础
- Xin'an Second Edition: Chapter 26 big data security demand analysis and security protection engineering learning notes
- yarn : 无法加载文件 D:\ProgramFiles\nodejs\yarn.ps1,因为在此系统上禁止运行脚本
- Flexible report v1.0 (simple version)
- Xin'an Second Edition; Chapter 11 learning notes on the principle and application of network physical isolation technology
- [reverse primary] Unique
- 分布式(一致性协议)之领导人选举( DotNext.Net.Cluster 实现Raft 选举 )
- Total / statistics function of MySQL
猜你喜欢
面试突击62:group by 有哪些注意事项?
05 personal R & D products and promotion - data synchronization tool
Final review of information and network security (full version)
Flink parsing (III): memory management
面试突击63:MySQL 中如何去重?
Chrome prompts the solution of "your company management" (the startup page is bound to the company's official website and cannot be modified)
04个人研发的产品及推广-数据推送工具
Final review of information and network security (based on the key points given by the teacher)
BearPi-HM_ Nano development environment
TCP连接不止用TCP协议沟通
随机推荐
Openharmony developer documentation open source project
Wordcloud colormap color set and custom colors
07 personal R & D products and promotion - human resources information management system
Essai de pénétration du Code à distance - essai du module b
Selenium test of automatic answer runs directly in the browser, just like real users.
Huawei certified cloud computing hica
05个人研发的产品及推广-数据同步工具
The solution to the left-right sliding conflict caused by nesting Baidu MapView in the fragment of viewpager
Final review of information and network security (full version)
Display picture of DataGridView cell in C WinForm
FlutterWeb瀏覽器刷新後無法回退的解决方案
视频融合云平台EasyCVR增加多级分组,可灵活管理接入设备
[translation] principle analysis of X Window Manager (I)
Compile and build, from the bottom to the top
全网最全tcpdump和Wireshark抓包实践
Flink parsing (VII): time window
OpenCV中如何使用滚动条动态调整参数
Unity粒子特效系列-闪星星的宝箱
C WinForm series button easy to use
面试突击62:group by 有哪些注意事项?