I'm trying to use SQL
to upload a csv
file from my laptop to a database, however I get a strange error. The code I am typing into the SQL window in phpMyAdmin is as follows:
LOAD DATA INFILE '/Users/myMac/testServerUpload.csv'
INTO TABLE `testDatabase`
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'
But I get the following error:
Error
SQL query:
LOAD DATA INFILE '/Users/myMac/testServerUpload.csv' INTO TABLE `testDatabase` FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'
MySQL said: Documentation
#1045 - Access denied for user 'ukld'@'%' (using password: YES)
Should I be using LOAD DATA LOCAL INFILE
instead of my current command as the file is on my computer? Both give me an error, and I thought LOCAL
might mean that it is on the server. I could not find relevant advice searching for this error.
I had this same issue and fixed it by using LOCAL and giving the full file path:
'C:/directory/file.csv'
It seems the 1045 error comes from not having access to files on the server, which is where mySQL looks for the file if LOCAL is not specified.
See also: