Change SQLite database mode to read-write

2019-01-22 00:59发布

How can I change an SQLite database from read-only to read-write?

When I executed the update statement, I always got:

SQL error: attempt to write a readonly database

The SQLite file is a writeable file on the filesystem.

标签: sqlite3
14条回答
家丑人穷心不美
2楼-- · 2019-01-22 01:42

(this error message is typically misleading, and is usually a general permissions error)

On Windows

  • If you're issuing SQL directly against the database, make sure whatever application you're using to run the SQL is running as administrator
  • If an application is attempting the update, the account that it uses to access the database may need permissions on the folder containing your database file. For example, if IIS is accessing the database, the IUSR and IIS_IUSRS may both need appropriate permissions (you can try this by temporarily giving these accounts full control over the folder, checking if this works, then tying down the permissions as appropriate)
查看更多
Explosion°爆炸
3楼-- · 2019-01-22 01:43

On Linux, give read/write permissions to the entire folder containing the database file.

Also, SELinux might be blocking the write. You need to set the correct permissions.

In my SELinux Management GUI (on Fedora 19), I checked the box on the line labelled httpd_unified (Unify HTTPD handling of all content files), and I was good to go.

查看更多
登录 后发表回答