Troubleshooting "access denied for load data infile" Error in MySQL
When attempting to use the LOAD DATA INFILE command in MySQL, users may encounter the following error:
#1045 - Access denied for user 'user'@'localhost' (using password: YES)
This error indicates that the current user does not have sufficient permissions to perform the LOAD DATA INFILE operation.
Resolution:
To resolve this issue, it is necessary to grant the user the FILE privilege on the database in question. This can be done using the following syntax:
GRANT FILE ON *.* TO 'user'@'localhost';
Alternatively, you can add the LOCAL keyword to the LOAD DATA INFILE statement, which will grant the user temporary privileges to load the data from a local file. The modified statement would look like this:
LOAD DATA LOCAL INFILE 'file.txt' INTO TABLE `my_table`;
The above is the detailed content of Why am I getting the \"access denied for load data infile\" error in MySQL?. For more information, please follow other related articles on the PHP Chinese website!