1

I have an MySql query from which i generate a OUTFILE (.csv) which i save it in /tmp . Please find the query below :

SELECT 'Artifact ID' id, 'Related Links' new_value UNION select CONCAT(si.ID_PREFIX, si.ID_COUNT) as ID, tmp.NEW_VALUE from ( select ACTIVITY_ID, ISSUE_ID, OLD_VALUE, NEW_VALUE from SCARAB_ACTIVITY where ISSUE_ID in (select ISSUE_ID from SCARAB_ISSUE where MODULE_ID = 775)  and (NEW_VALUE like 'http%') order by ACTIVITY_ID desc) tmp, SCARAB_ISSUE si where tmp.ISSUE_ID = si.ISSUE_ID INTO OUTFILE '/tmp/flexsustain_test_relatedlinks.csv' FIELDS ENCLOSED BY '' TERMINATED BY ',';

I have already tried to configure /etc/my.cnf file

[mysqld]
datadir=/var/lib/mysql
tmpdir = /var/lib/mysql/tmp
socket=/var/lib/mysql/mysql.sock
read-only = 0

and also i gave full permissions to tmpdir. But when i run the query not sure where the file is saved. Any suggestions ?

11
  • Can you show the query that you used for this?
    – StefanR
    Commented Mar 6, 2017 at 8:13
  • @StefanR please find the query below : SELECT 'Artifact ID' id, 'Related Links' new_value UNION select CONCAT(si.ID_PREFIX, si.ID_COUNT) as ID, tmp.NEW_VALUE from ( select ACTIVITY_ID, ISSUE_ID, OLD_VALUE, NEW_VALUE from SCARAB_ACTIVITY where ISSUE_ID in (select ISSUE_ID from SCARAB_ISSUE where MODULE_ID = 775) and (NEW_VALUE like 'http%') order by ACTIVITY_ID desc) tmp, SCARAB_ISSUE si where tmp.ISSUE_ID = si.ISSUE_ID INTO OUTFILE '/tmp/flexsustain_test_relatedlinks.csv' FIELDS ENCLOSED BY '' TERMINATED BY ','; Commented Mar 6, 2017 at 8:13
  • Please update it to the question.
    – StefanR
    Commented Mar 6, 2017 at 8:14
  • @StefanR i have updated it Commented Mar 6, 2017 at 8:22
  • 2
    You have configured tmpdir to be /var/lib/mysql/tmp, but you save the file under /tmp in that query. Did you check from /tmp ?
    – StefanR
    Commented Mar 6, 2017 at 8:23

1 Answer 1

0

You have specified /var/lib/mysql/tmp as temporary directory in your configuration for the database server, but you did specify in the query that the file should be saved under /tmp. So you should find the file resulting from that query under the /tmp directory.

But if you are using a server with systemd and you have privatetemp enabled for db, then that file probably will be stored under a privatetemp folder even if you specify absolute path in the query. Private temp folder will be something like /tmp/systemd-mariadb.service-XXXXXXX/tmp/outfile.csv.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .