Home >Database >Mysql Tutorial >Why Am I Getting \'Access Denied for LOAD DATA INFILE\' Errors in MySQL?
Troubleshooting "Access Denied for LOAD DATA INFILE" Errors in MySQL
When executing LOAD DATA INFILE queries in MySQL, you may encounter an "Access denied" error, leaving you wondering about the cause. This issue commonly arises when attempting to load data from a local file into a database table.
The error message indicates that the user attempting to execute the query does not have the necessary permissions to perform the operation. Typically, users are granted standard data manipulation privileges, but may not have explicit permissions for loading data via the LOAD DATA INFILE command.
To resolve this issue, you must grant the appropriate permissions to the user. This involves adding the FILE privilege to the user's privileges. The FILE privilege allows users to read and write files on the server.
To grant the FILE privilege, you can connect to MySQL as a root user and execute the following query:
<code class="sql">GRANT FILE ON *.* TO <user>@'<host>';</code>
Replace
Once you have granted the FILE privilege, try executing the LOAD DATA INFILE query again. It should now run successfully without the access denied error. Remember to refresh the privileges by flushing them using the FLUSH PRIVILEGES command for the changes to take effect.
The above is the detailed content of Why Am I Getting \'Access Denied for LOAD DATA INFILE\' Errors in MySQL?. For more information, please follow other related articles on the PHP Chinese website!