问题描述
我试图将CSV文件写入 / var / www / VistaMind_CMStmp
,但出现错误消息: SQLSTATE [HY000]:常规错误:1无法创建/写入文件'/VistaMind_CMS/tmp/app_users.csv'(错误代码:2)
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)
做 mysql:mysql
/ var / www / VistaMind_CMS / tmp
,但这是行不通的。我不想修改my.cnf中的TMPDIR变量,该变量当前设置为/ var / www,但我希望MySQL将数据库表转储到/ var / www / VistaMind_CMS / tmp。
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.
请帮助!
我的代码是:
$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!!";
推荐答案
您需要执行 own mysql:mysql / var / www / VistaMind_CMS / tmp
。
这篇关于一般错误:1无法创建/写入文件errcode:2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!