php sqlite 权限

本文介绍了一种在使用PHP执行SQLite数据库操作时遇到的奇怪行为。当尝试使用exec执行查询时,即使数据库文件已设置为可读写,仍可能会收到无法打开数据库文件的错误。解决方法是确保数据库文件及其所在目录对于Web服务器/PHP运行的用户具有写权限。

php官网一段留言

IMPORTANT! just a note: 

weird behaviour when doing an exec on a sqlite db!!!

if want to execute a query on a sqlite db with exec, and your dbfile already was e.g. mode 777, and you get some php errors saying

"SQLite3::exec(): unable to open database file in ...."

and you get crazy while debugging, just add write üermissions to the whole directory for the user the webserver/php runs.

this behaviour makes absolutely NO sense, and is a source of frustration.
at least a more meaningful errormessage would be nice.
i couldnt figure out why sqlite needs write permissions for the whole dir instead of only one file. this is stupid and must be a bug!
(to be secure you have to create a directory with write permissions only for php/apache)

大意是:把数据库放到一个另外文件夹(不影响其他文件),设置读写权限

纠结的是:数据库和数据库所在的文件夹都要可写(可能是因为写数据库时,需要建立一个临时文件)

具体用到就是 chmod

转载于:https://www.cnblogs.com/d20062303732/p/4379708.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值