我正在尝试将 CSV 文件写入/var/www/VistaMind_CMStmp
并收到错误消息:SQLSTATE[HY000]: General error: 1 Can't create/write to file '/VistaMind_CMS/tmp/app_users.csv' (Errcode: 2)
我试过做chown mysql:mysql
/var/www/VistaMind_CMS/tmp
,但这不起作用。我不想修改 my.cnf 中的 TMPDIR var,它当前设置为 /var/www,而是希望 MySQL 将数据库表转储到 /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!!";