0
votes

Trying to load CSV data to remote MySQL Server using following command in MySQL Server 5.5, and using PHP-5.6 PDO connection.

LOAD DATA INFILE :file INTO TABLE test_csv COLUMNS 
TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n';

But i'm getting the following error:

PHP Warning: chown(): Unable to find uid for mysql in /var/www/proj/csvtodb.php on line 22 2017-12-26 09:21:18,

SQLSTATE[HY000]: General error: 13 Can't get stat of '/tmp/csvfile-1.csv' (Errcode: 2)

Please help us to fix this issue.

1
Is the file located on the remote server or on the client server? If it's on the client server, you need to use LOAD DATA LOCAL INFILE. - Barmar
The first warning has nothing to do with the MySQL query, it's from a call to chown() earlier in the script. - Barmar
@barmar: csv file is in client server only - sk2

1 Answers

0
votes

If the CSV file is located on the PHP server running the script, not the remote MySQL server, you need to use LOAD DATA LOCAL INFILE. LOAD DATA INFILE looks for the file on the MySQL server.