问题
This is no longer a problem.... see below at end.
I am getting the following MySQL error while trying to LOAD a table from a file in a CRON job. Access denied for user 'laurel'@'localhost' (using password: YES)
This is the LOAD statement:
$LoadQuery="load data local infile 'http://example.com/~laurel/csvfiles/handicaps.csv'
into TABLE handicap fields terminated by ','";
(the IP address is actually being used in the path instead of example.com) The LOAD works when I run it within the website, from the URL line and from phpMyAdmin. I can do everything else in the CRON job with this user including inserting to a table and deleting a table. Everything except LOAD. When I try running it without the 'local' coded I get the same access error. And, without 'local' in the statement I receive the Access Error when running the query from the website and from phpMyAdmin. It works from the website and from phpMyAdmin only when 'local' is included.
When I look at the permissions for this user from the cPanel ALL PRIVILEGES, as well as the following individual priveleges are checked:
ALL PRIVILEGES
ALTER CREATE
CREATE ROUTINE CREATE TEMPORARY TABLES
CREATE VIEW DELETE
DROP EXECUTE
INDEX INSERT
LOCK TABLES REFERENCES
SELECT SHOW VIEW
TRIGGER UPDATE
What am I missing? Why isn't this user able to do a LOAD function? Thank you in advance for your help
This is no longer a problem. I made the following change to the LOAD statement and it worked: $LoadQuery="load data local infile \"../csvfiles/handicaps.csv\" into TABLE handicap fields terminated by ','";
回答1:
This is no longer a problem.
I made the following change to the LOAD statement and it worked: $LoadQuery="load data local infile \"../csvfiles/handicaps.csv\" into TABLE handicap fields terminated by ','";
来源:https://stackoverflow.com/questions/25040589/access-denied-in-php-cron-job-for-only-load-operation