Import a large csv file using phpMyAdmin

I have a csv file, large, 30,000 lines. I tried to import it using a LOAD file, etc. From the terminal, as I found on Google, but that didn't work. He did the import, but my table hit 30,000 NULL rows.

After that I tried phpMyAdmin and there I found out that my csv was too big. I split it into 5 using CSV Splitter. I made an import for the first file. Everything went perfectly. Than I tried to import the second, but I got this error:

Fatal error: valid memory size 134217728 bytes exhausted allocate 35 bytes) in C: \ xampp \ phpMyAdmin \ libraries \ import \ csv.php on line 370

or error 1064.

Do you know why and how I can solve this? Thanks.

+6
source share
2 answers

Increase php memory limit and script time, which will lead to mysql command execution through php server.

Check your php.ini file for these vars:

memory_limit max_execution_time 

But in any case, I would do it via mysql client (terminal), check mysql doc

 LOAD DATA LOCAL INFILE '/path/to/your/csv/file/csv_file.csv' INTO TABLE database_name.table_name FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'; 

Mysql Documentation - Data Load Syntax Syntax PHP Documentation - Ini Internal Settings

+20
source

I had a problem trying to import a large file using phpMyAdmin, and I also cannot use this command in the version used. To solve this problem, I used this CSV editor and split the file into smaller files. It worked fine when I imported each piece separately.

+1
source

Source: https://habr.com/ru/post/920205/


All Articles