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>
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!