简体   繁体   中英

how to import a text file into phpmyadmin or mysql database

I have a text file with 400k of data named data.txt example

row1,row2,row3
1111,2222,33333
4444,5555,6666
777,8888,9999
1010101010,111111111,12121212
13313131313,14141414141414,151515151515

but when i try to import it directly it gives error

I want to import it to a database named 'dataflow.sql'

and let it create 3 rows with the names from the example and fetch the data based on the comas

any help is appreciated

You'll have to craft a SQL request using LOAD DATA:

LOAD DATA INFILE '/path/to/data.txt' 
INTO TABLE my_table 
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;

https://dev.mysql.com/doc/refman/8.0/en/load-data.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM