Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to transfer big .txt file to MySQL?

Tags:

php

mysql

I have a very big .txt file of millions of strings and it has separation sign.

So, what is the easiest way to transfer all those strings to database? Is it PHP fopen and taking every string with explode and inserting it into database?

FILE IS 2 GB.

like image 686
good_evening Avatar asked Jan 19 '23 02:01

good_evening


1 Answers

Use phpmyadmin to generate the command for you, ie.:

LOAD DATA LOCAL INFILE 'input_file' INTO TABLE `tablename` FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n'

Quoted from http://vegdave.wordpress.com/2007/05/19/import-a-csv-file-to-mysql-via-phpmyadmin/

like image 175
boj Avatar answered Jan 21 '23 15:01

boj