Home > Database > Mysql Tutorial > body text

How to Fix \'Access Denied\' Errors When Using LOAD DATA INFILE in MySQL?

Barbara Streisand
Release: 2024-10-31 05:48:02
Original
269 people have browsed it

How to Fix

Troubleshooting Access Denied Errors for LOAD DATA INFILE Operation in MySQL

When executing a LOAD DATA INFILE query in MySQL using PHP, encountering the error "Access denied for user 'user'@'localhost' (using password: YES)" can arise. This signifies that the user lacks the necessary privileges to perform the operation.

To rectify this issue, it is essential to grant the user the FILE privilege. By adding the keyword LOCAL to the LOAD DATA INFILE statement, this privilege is implicitly granted.

Example:

To demonstrate, consider the following statement that causes the access denied error:

LOAD DATA INFILE 'file_name.csv'
INTO TABLE table_name;
Copy after login

To correct this statement and enable the operation, simply add LOCAL to the query:

LOAD DATA LOCAL INFILE 'file_name.csv'
INTO TABLE table_name;
Copy after login

By making this modification, the user will be granted temporary FILE privileges, allowing the data loading operation to proceed without encountering any permission-related errors.

The above is the detailed content of How to Fix \'Access Denied\' Errors When Using LOAD DATA INFILE in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!