简体   繁体   English

Laravel 5.1 PHP Artisan迁移并显示错误消息PDOException找不到驱动程序

[英]Laravel 5.1 php artisan migrate with error message PDOException could not find driver

I'm trying to connect to the PostgreSQL database through laravel in order to make a php artisan migrate , but I get the error 我正在尝试通过laravel连接到PostgreSQL数据库,以使php artisan迁移,但是我得到了错误

[PDOException] could not find driver [PDOException]找不到驱动程序

looking at similar questions found there to enable extensions in php.ini but did not solve my problem, still gives me the same error. 查看那里发现的类似问题以启用php.ini扩展名,但未能解决我的问题,仍然给出了相同的错误。

In other parts of my code I use the database and I can add records so I think my settings database right. 在代码的其他部分,我使用数据库,并且可以添加记录,因此我认为我的设置数据库正确。 I do not understand the error. 我不明白该错误。

Database.php file: Database.php文件:

<?php return [ 
      'fetch' => PDO::FETCH_CLASS, 
      'default' => env('DB_CONNECTION', 'pgsql'), 
      'connections' => [ 
             'pgsql' => [ 
                  'driver' => 'pgsql', 
                  'host' => env('DB_HOST', 'localhost'), 
                  'database' => env('DB_DATABASE', 'forge'), 
                  'username' => env('DB_USERNAME', 'forge'), 
                  'password' => env('DB_PASSWORD', ''), 
                  'charset' => 'utf8', 'prefix' => '', 
                  'schema' => 'public', 
              ], 
        ], 
        'migrations' => 'migrations', 
  ]; ?>

Check if you have pdo_pgsql extention. 检查是否具有pdo_pgsql扩展。

You can 您可以

php -i | grep pgsql

to see it. 看见了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM