mysql imports data in different file formats

Record the problem of mysql database importing data in different formats.

Recently, I am learning from other people's websites (how can the things of scholars be called copying), and I need to import the data into my own database bit by bit. At first, I felt that the data was quite small, so I typed sql commands line by line to import a little bit. Later, I felt that it was too slow. Anyway, I am a half-hearted programmer, and manual import is too low-level.

So I wrote a crawler (life is short, learn python quickly) to crawl the desired data, save it in a file, and then use the import function that comes with mysql to import the data into my table.

I won’t talk about crawling data, let’s talk about several methods of importing external data.

.sql file

As mentioned before, this file format is relatively simple to import

mysql -u root -p wordpress < /usr/local/wordpress.sql #这句意思是把wordpress.sql文件导入到wordpress数据库中

Only one command is needed to import successfully.

.txt file

This is an ordinary file format, and it is the same under Linux with or without a file suffix.

Suppose the file format is as follows

3,智影,腾讯出品在线智能视频创作平台,https://zenvideo.qq.com/home
4,极简简历,简单优质的在线简历制作平台,https://www.polebrief.com/index
5,白描OCR,白描OCR网页版、图片文字提取、PDF转文字,https://web.baimiaoapp.com/
6,PDF 在线工具箱,支持24种PDF在线编辑功能,https://tools.pdf24.org/zh/
7,树图思维导图,免费的在线思维导图工具网站,https://shutu.cn/
8,网易见外工作台,网易自营的智能转写翻译服务,https://jianwai.youdao.com/

Each field is separated by ',' . Of course, other separators can also be used for separation. The separator is preferably one that does not appear in your data.

Use the following command to import it into a table in the database.

load data local infile "/home/date" into table workonline FIELDS TERMINATED BY ',';
此命令含义是把/home/data里面的数据导入到当前数据库里的workonline表里,每个字段以‘,’分开

 

Link to this article: https://xiaoliu.life/652.html

Please indicate the reprint from: Xiao Liu who loves to work overtime

Guess you like

Origin blog.csdn.net/weixin_46630782/article/details/128362961