20

I am running into a permission error when trying to load data from a flat file database dump into a new table. I know that the schema of the file and my table is the same and I tried tweaking the permissions. What else should I try?

mysql> load data infile 'myfile.txt' into table mytable fields terminated by ',' enclosed by '"';
ERROR 1045 (28000): Access denied for user 'user'@'%' 

grant all on mytable.* to 'user'@'%
4
  • 4
    See also What file and directory permissions are required for MySQL LOAD DATA INFILE? (try changing LOAD DATA INFILE 'myfile.txt' to LOAD DATA LOCAL INFILE 'myfile.txt' Commented Jan 20, 2014 at 14:39
  • possible duplicate of access denied for load data infile in MySQL Commented Apr 29, 2014 at 17:21
  • @DannyBeckett solution with 'LOCAL' might not be available for all mysql versions. For instance , for '5.7.34-log' won't work. Commented May 3, 2022 at 13:44
  • Correcting myself, The above solution with 'LOCAL' might require an additional set of the property 'allowLoadLocalInfile' to 'TRUE'. Commented May 3, 2022 at 13:51

2 Answers 2

40

Here's a thread on the MySQL forums that discusses exactly this.

Here's the answer, posted by Ken Tassell

Problem resolved using the command below:

grant file on *.* to kentest@localhost identified by 'kentest1';
Sign up to request clarification or add additional context in comments.

Comments

7

You might have MySQL privileges on the destination table, but you also need the FILE privilege to execute LOAD DATA, and of course the MySQL Server process needs operating-system privileges to the data file too.

1 Comment

Thank you for the description of the problem. Helped me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.