Home > Database > Mysql Tutorial > body text

How to Resolve \'LOAD DATA LOCAL INFILE Permission Denied\' in PHP?

Linda Hamilton
Release: 2024-11-06 02:11:02
Original
670 people have browsed it

How to Resolve

LOAD DATA LOCAL INFILE Permission Denied in PHP

When using LOAD DATA INFILE with the LOCAL option, users may encounter permission errors when accessing the file from PHP applications. This issue is attributed to the compilation settings of PHP and the use of mysqlnd.

To resolve this problem, users can set the PDO::MYSQL_ATTR_LOCAL_INFILE attribute to true during PDO instantiation:

<code class="php">$conn = new \PDO("mysql:host=$server;dbname=$database;", "$user", "$password", array(
    PDO::MYSQL_ATTR_LOCAL_INFILE => true,
));</code>
Copy after login

By enabling this attribute, PHP will be granted permission to access local files when executing the LOAD DATA LOCAL INFILE command. This allows users to conveniently load data into MySQL tables from files located on the server.

The above is the detailed content of How to Resolve \'LOAD DATA LOCAL INFILE Permission Denied\' in PHP?. 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