我有一个PHP脚本,可以使用LOAD DATA INFILE将csv文件导入MySQL表。该查询适用于MySQL内的root用户和非root用户,但是当从PHP脚本运行查询时,它只适用于root用户。
我非常确定我已正确设置所有权限,甚至通过向非root用户授予完全权限进行测试。
我是否有任何可能阻止用户运行查询的内容?
这是脚本:
$files = scandir('/var/www/html/imports/pigsback/');
foreach($files as $file) {
if ($file != '.' && $file != '..') {
$import =
"LOAD DATA INFILE '/var/www/html/imports/pigsback/$file'
IGNORE INTO TABLE pigsback.temp_import
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(@deal_id, @voucher_headline, @item_sku, @purchase_date, @first_name, @last_name, @address_1, @address_2,
@address_3, @address_4, @postcode, @region, @phone, @delivery_note, @sequence_id, @deal_price, @country)
SET deal_id=@deal_id, voucher_headline=@voucher_headline, item_sku=@item_sku, purchase_date=@purchase_date,
first_name=@first_name, last_name=@last_name, address_1=@address_1,address_2=@address_2, address_3=@address_3,
address_4=@address_4, postcode=@postcode, region=@region, phone=@phone, delivery_note=@delivery_note,
sequence_id=@sequence_id, deal_price=@deal_price, country=@country";
if(! mysqli_query($connect, $import)) {
echo 'Failed: ' . $file . PHP_EOL;
}
else {
}
}
}