我正在尝试删除db.sqlite文件,再次创建它,然后在同一个方法中插入一些信息,这是我正在使用的方法:
public function destroy()
{
// Store all contents and delete the first one since this is created via seeder
$contents = $this->contents->all()->toArray();
array_shift($contents);
// Delete db file, creates it from an example file and changes permissions
system('rm -rf ../database/database.sqlite');
system('cp ../database/database.sqlite.example ../database/database.sqlite');
system('chmod 0777 ../database/');
system('chmod 0777 ../database/database.sqlite');
// Insert data
foreach ($contents as $content) {
$this->contents->create($content);
}
return response()->json(['message' => 'Data has been destroyed!']);
}
但是,当我尝试运行它时,我得到标题上描述的错误:
SQLSTATE [HY000]常规错误:8尝试编写只读数据库
我给了文件的777权限和其他问题答案推荐的文件夹,所以我不知道为什么它不起作用.
解决方法:
你需要继续推行
首先,将laravel目录的所有权更改为Web组
sudo chown -R:www-data / var / www / yourLarvelFolder
授予存储目录权限,使其可写.
sudo chmod -R 775 /var/www/yourLarvelFolder/storage
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!