I have looked all over and found no solution, any help on this would be great.
Query:
LOAD DATA INFILE '/Users/name/Desktop/loadIntoDb/loadIntoDB.csv' INTO TABLE `tba`.`tbl_name` FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES ( field1, field2, field3 )
Error:
Can't get stat of '/Users/name/Desktop/loadIntoDb/loadIntoDB.csv' (Errcode:2)
NOTE:
I'm running MySQL Query browser on OSX 10.6.4 connecting to MySQL 5.x
Things I've tried:
If you get Errcode 13 (which means Permission denied ) when starting mysqld, this means that the privileges of the data directory or its contents do not permit server access. In this case, you change the permissions for the involved files and directories so that the server has the right to use them.
For the mysql client, local data loading capability is determined by the default compiled into the MySQL client library. To disable or enable it explicitly, use the --local-infile=0 or --local-infile[=1] option.
The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. If the LOCAL keyword is specified, the file is read from the client host. If LOCAL is not specified, the file must be located on the server.
try to use LOAD DATA LOCAL INFILE
instead of LOAD DATA INFILE
otherwise check if apparmor is active for your directory
I had a similar problem. The resolution was a mildly ugly hack, but much easier to remember than apparmor workarounds provided that you can 'sudo'. First, I had to put the input file in the mysql sub-directory for the database I was using:
sudo cp myfile.txt /var/lib/mysql/mydatabasename
This does a copy and leaves 'root
' as the file owner. After getting into mysql and doing a USE mydatabasename
, I was able to populate appropriate table using
LOAD DATA INFILE 'mytabdelimitedtextfile.txt' INTO TABLE mytablename;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With