Folder /var/www/html/new_7alaqa/public/dumpfiles/ owned by mysql:mysql and i'm trying to run:
$note_file= time().$user_idd."_".$halaqa_idd.$typed."note.txt";
$note_query="select * from notes where is_deleted = 0 and halaqa_id=".$halaqa_idd." into outfile '/var/www/html/new_7alaqa/public/dumpfiles/$note_file' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '),\n(';";
DB::select($note_query);
Edit: from mysql commands: working in /tmp directory and default directory
select * from users into outfile '/var/www/html/new_7alaqa/public/dumpfiles/11.txt';
ERROR 1 (HY000): Can't create/write to file '/var/www/html/new_7alaqa/public/dumpfiles/11.txt' (Errcode: 13 - Permission denied)
mysql> select * from users into outfile '/tmp/11.txt';
Query OK, 1417 rows affected (0.00 sec)
Depending on your server/db/user accounts set up, here are some things to try:
dumpfiles
to www-data
:sudo chown -R www-data:www-data dumpfiles
You can revert by running
sudo chown -R mysql:mysql dumpfiles
FILE
permission to your MySQL user.GRANT FILE ON *.* TO user;
FLUSH PRIVILEGES;
It's important to note that even if you already gave your user all permissions by running GRANT ALL
, it doesn't include the FILE
permission.
$dumpFilePath = addslashes('/var/www/html/new_7alaqa/public/dumpfiles/$note_file');
$note_query="select * from notes where is_deleted = 0 and halaqa_id=".$halaqa_idd." into outfile '$dumpFilePath' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '),\n(';";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.