首页 > 解决方案 > Laravel Sqlite 数据库无法连接

问题描述

当我导航到我的服务器(Ubuntu)上的应用程序时,我得到以下信息:

Data: { message: 'could not find driver (SQL: select * from "projects" order by "created_at" desc)',
  exception: 'Illuminate\\Database\\QueryException',
  file: '/root/project/api/vendor/laravel/framework/src/Illuminate/Database/Connection.php',
  line: 664,
  trace:
   [ { file: '/root/project/api/vendor/laravel/framework/src/Illuminate/Database/Connection.php',
       line: 624,
       function: 'runQueryCallback',
       class: 'Illuminate\\Database\\Connection',
       type: '->' },

但是在本地它可以工作。所以我想也许驱动程序没有安装,但是当我运行以下命令时,它显示我已经安装了 sqlite:

 sqlite3 -version
3.19.3 2017-06-08 14:26:16 0ee482a1e0eae22e08edc8978c9733a96603d4509645f348ebf55b579e89636b

我的数据库配置如下所示,默认为 sqlite:

'sqlite' => [
            'driver' => 'sqlite',
            'database' => env('DB_DATABASE', database_path('database.db')),
            'prefix' => '',
        ],

我下一步要弄清楚为什么这不起作用?

标签: phplaravelubuntusqlite

解决方案


您已经安装了 sqlite3,但没有安装 php 的驱动程序。该驱动程序也称为 sqlite3,因此对于例如 Ubuntu/Debian,它将是sudo apt-get install php7.2-sqlite3.


推荐阅读