Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Import a database from a text file

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Import data from text files

mysql> load data [local] infile '/test/file1.txt' into table sinfo fields terminated by

' ' enclosed by '"' escaped by '"' lines terminated by '\r';

fields terminated by field delimiter, default is tab

enclosed by '"' escaped by '"' Whether the contents of each field are enclosed in a specific character, such as "name"

lines terminated by delimiter for each record line, default is carriage return "\n"

Exercise: import ip address, access protocol and status, number of bytes transferred, request method, access url and port from access.log.1 file into

database, and ask for numbers at the top, starting with 1.

1222441666.045 0 192.168.20.171 TCP_DENIED/403 1869 CONNECT urs.microsoft.com:443 - NONE/- text/html

192.168.20.171 TCP_DENIED/403 1869 CONNECT urs.microsoft.com:443

The fields of the record are:

id ipaddr pstats fsize method url

1 192.168.20.171 TCP_DENIED/403 1869 CONNECT urs.microsoft.com:443

2. Export data to text files

mysql> select * from employees into outfile '/test/employees.txt';

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report