Question

I am trying to write a CSV file to /var/www/VistaMind_CMStmp and I get the error Message: SQLSTATE[HY000]: General error: 1 Can't create/write to file '/VistaMind_CMS/tmp/app_users.csv' (Errcode: 2)

I tried doing chown mysql:mysql /var/www/VistaMind_CMS/tmp, but that does not work. I do not want to modify my TMPDIR var in my.cnf, which is currently set to /var/www, but instead, I want MySQL to dump a database table to /var/www/VistaMind_CMS/tmp.

Please help!

My code is :

    $file_path = $this->view->baseUrl()."/../tmp/app_users.csv";
    $sql = "SELECT * FROM users INTO OUTFILE '".$file_path."' ".
            "FIELDS TERMINATED BY ','
            ENCLOSED BY '\"'
            LINES TERMINATED BY '\n'";
    $db = Zend_Registry::get('db');
    $stmt = $db->query($sql, array());
    echo "Done!!";
Was it helpful?

Solution

You need to do chown mysql:mysql /var/www/VistaMind_CMS/tmp.

OTHER TIPS

in my case the chown did not fix the problem. I followed the second step in the following post which finally solved my problem

http://www.mydailyhacks.org/2014/11/08/how-can-i-backup-a-mysql-database-or-export-it-to-a-file/

(I had to change the tmpdir used by mysql)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top