最明顯的情況是缺少寫入當前工作目錄的權限。這是確切的錯誤消息,我在這種情況下(太糟糕了它不打擾到包括像拒絕「權限」有用的信息)獲取
如果你有機會獲得strace
,那麼你就可以確認這樣的:
$ strace -f sqlite3 ex1.db 'create table tb11(one varchar(10), two smallint);' 2>&1 | grep ex1.db
execve("/usr/bin/sqlite3", ["sqlite3", "ex1.db", "create table tb11(one varchar(10"...], [/* 58 vars */]) = 0
access("ex1.db", F_OK) = -1 ENOENT (No such file or directory)
stat("/tmp/d/ex1.db", 0x7fffb18fc690) = -1 ENOENT (No such file or directory)
open("/tmp/d/ex1.db", O_RDWR|O_CREAT, 0644) = -1 EACCES (Permission denied)
open("/tmp/d/ex1.db", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "Error: unable to open database \""..., 70Error: unable to open database "ex1.db": unable to open database file
注意open
的結果是EACCESS (Permission denied)
。
多數民衆贊成多數民衆贊成,因爲它太精簡提供錯誤消息 –
@derobert謝謝,我想我想通了。我只是改變了我所在的目錄,並且能夠創建數據庫,因此很可能沒有權限。 –