Error with invalid package during MySQL LOAD DATA LOCAL INFILE

I am trying to upload a file to MySQL innodb table (v5.1.38) using PHP mysqli :: query and a LOAD DATA LOCAL INFILE query . The query returns the error code "Malformed packet" 2027. Any ideas what is wrong?

Here is the target table:

CREATE TABLE `zbroom`.`lee_datareceive` ( `a` varchar(45) NOT NULL, `b` varchar(45) NOT NULL, `c` varchar(45) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 

Here is the request:

 LOAD DATA LOCAL INFILE '/path/to/file.txt' INTO TABLE lee_datareceive FIELDS TERMINATED BY '\t'; 

Here is the file data. The values ​​are divided into the tab:

 t1 t2 t3 abc def ghi 
+1
source share
1 answer

same problem. it was a resolution problem.

shell exec from php:

 'mysql --user=root --password=zxc db < /stuff.sql' 

stuff.sql

 LOAD DATA LOCAL INFILE '/stuff.csv' INTO TABLE `stuff` FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' 

Errors with invalid packages.

Decision:

 chmod 777 /stuff.csv 

PHP runs at its own permission level, and mysql does not get read access to stuff.csv

You get a cookie if you hate chmod 777

0
source

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


All Articles