0

I have a node js project with folder output. This folder has 777 permissions. I query SELECT INTO OUTFILE via node-mysql.

But I have Errcode: 13 - Permission denied error.

MySQL started with secure_file_priv=""

SQL: SELECT * FROM users INTO OUTFILE '/home/ubuntu/Projects/output/1.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n';

Tryam
  • 375
  • 2
  • 13
  • good to know? what about the code? – Lelio Faieta Feb 15 '19 at 12:05
  • @LelioFaieta, I added my sql query – Tryam Feb 15 '19 at 12:08
  • try to change the url of the file as relative to the root folder of your project and not as an absolute url – Lelio Faieta Feb 15 '19 at 12:10
  • @LelioFaieta, mysql changes it to `/var/lib/mysql/output/` – Tryam Feb 15 '19 at 12:12
  • @Tryam Check this similar question which may help you: https://stackoverflow.com/questions/2783313/how-can-i-get-around-mysql-errcode-13-with-select-into-outfile – floss Feb 15 '19 at 12:40
  • i pretty sure your MySQL server is configured to allow making a file in one directory only to prevent possible backdoors (webshells generating codes) from happing when SQL injections are possible with `‘ union select “ system($_REQUEST[‘cmd’]); ?>”, INTO OUTFILE ‘/var/www/test/execcmd.php’#` (PHP example pretty sure it's also possible with Node.js) and would allow making the file everywhere. – Raymond Nijland Feb 15 '19 at 14:22

0 Answers0