0
下的MySQL OUTFILE奇怪的問題(見我的回答如下。萬一離開這件事它可以幫助別人。)從FreeBSD
接下來是一系列的嘗試傾倒在新的FreeBSD框中輸入查詢到outfile中的我的網站已轉移到。如果我以我身份登錄或者以root身份登錄,結果是一樣的。我希望這種風格不是太煩人。我的評論註釋了實際的代碼和輸出。
//試圖轉儲查詢到我的主目錄
SELECT pmr.datetime_requested,
nfo.postal_code
FROM
print_mailing_request pmr,
personal_info nfo
WHERE
nfo.person = pmr.person AND
pmr.datetime_requested >= "2010-01-01 00:00:00" AND
(pmr.print_mailing = 31 OR pmr.print_mailing = 30)
ORDER BY pmr.datetime_requested INTO OUTFILE '/usr/home/david/x';
ERROR 1 (HY000): Can't create/write to file '/usr/home/david/x' (Errcode: 2)
//嘗試創建文件先用觸摸,甚至搭配chmod 077文件 //但同樣的錯誤每次
// OK,讓我們試着/ tmp目錄
SELECT pmr.datetime_requested,
nfo.postal_code
FROM
print_mailing_request pmr,
personal_info nfo
WHERE
nfo.person = pmr.person AND
pmr.datetime_requested >= "2010-01-01 00:00:00" AND
(pmr.print_mailing = 31 OR pmr.print_mailing = 30)
ORDER BY pmr.datetime_requested INTO OUTFILE '/tmp/x';
Query OK, 24654 rows affected (0.78 sec)
//讓我們看一下這個文件
less /tmp/x
/tmp/x: No such file or directory
//重新登錄到MySQL,並嘗試同樣的查詢再次
ERROR 1086 (HY000): File '/tmp/x' already exists
ls /tmp
20100325180233.gtg2010.csv 20100330094652.gtg2010.csv
20100325180448.gtg2010.csv 2010_Q1_UNO.csv
20100325181446.gtg2010.csv 4724.csv
20100325181927.gtg2010.csv aprbUfvxp
20100326003002.gtg2010.csv dave.txt
20100327003002.gtg2010.csv etr.xml
20100328003002.gtg2010.csv mysql.sock
20100329003003.gtg2010.csv
//沒有文件X。
//如果我運行查詢沒有INTO OUTFILE我看到24000+行
| 2010-04-04 13:27:09 | 33156 |
| 2010-04-04 13:27:10 | 33156 |
| 2010-04-04 13:30:04 | NE38 8SR |
| 2010-04-04 14:27:03 | 00901 |
| 2010-04-04 14:37:04 | 75001 |
| 2010-04-04 14:53:05 | 78640 |
| 2010-04-04 15:15:03 | 07410 |
| 2010-04-04 15:27:04 | 43235 |
//所以我知道這是不是查詢...
//建議嗎?