Home  >  Article  >  Database  >  Why am I getting the \"access denied for load data infile\" error in MySQL?

Why am I getting the \"access denied for load data infile\" error in MySQL?

DDD
DDDOriginal
2024-11-01 00:35:28348browse

Why am I getting the

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn