So on my server here I have a process that ftps some data from a SQL server and loads it to MySQL. All was well until I got:
Can’t get stat of ‘/home/username/www/data’ (Errcode: 13)
I tried chmod and chown and running the file as root and everything. No success. I then found a post that said – move the file to /tmp. So I tried it and it worked! Here are my scripts.
Please note – you will have to add a user to mysql that has import permissions!
sql
truncate table equipment_in;
LOAD DATA INFILE ‘/tmp/equipment.csv’
REPLACE
INTO TABLE equipment_in
FIELDS TERMINATED BY ‘,’
OPTIONALLY ENCLOSED BY ‘”‘
LINES TERMINATED BY ‘\r\n’;
getdata
cd /tmp
rm *.csv*
wget ftp://username:password@servername/*.csv
mysql –user=username –password=thepassword databasename < /folder/with/the/sql