Php 将postgres与laravel连接起来
您好,我正在尝试将laravel 5.4与postgres连接,在更新数据库配置文件并运行Php 将postgres与laravel连接起来,php,postgresql,laravel,laravel-5,laravel-5.4,Php,Postgresql,Laravel,Laravel 5,Laravel 5.4,您好,我正在尝试将laravel 5.4与postgres连接,在更新数据库配置文件并运行php artisan migrate后,出现以下错误: [Illuminate\Database\QueryException] could not find driver (SQL: select * from information_schema.tables where t able_schema = public and table_name = migrations) [PDOExcepti
php artisan migrate
后,出现以下错误:
[Illuminate\Database\QueryException]
could not find driver (SQL: select * from information_schema.tables where t
able_schema = public and table_name = migrations)
[PDOException]
could not find driver
这是我的.env
文件
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=Portail
DB_USERNAME=php
DB_PASSWORD=php
'default' => env('DB_CONNECTION', 'pgsql'),
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'Portail'),
'username' => env('DB_USERNAME', 'php'),
'password' => env('DB_PASSWORD', 'php'),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer', ],
这是我的database.php
文件
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=Portail
DB_USERNAME=php
DB_PASSWORD=php
'default' => env('DB_CONNECTION', 'pgsql'),
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'Portail'),
'username' => env('DB_USERNAME', 'php'),
'password' => env('DB_PASSWORD', 'php'),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer', ],
我通常使用phpPgAdminsudo-apt-get-install-php-pgsql。这是在linux中安装php pgsql驱动程序的命令我发现解决方案有两个php.ini文件
- C:\wamp64\bin\apache\apache2.4.9\bin
- C:\wamp64\bin\php\php7.0.10
感谢您的帮助,我在使用php7.4的Ubuntu18.04上遇到了类似的问题 解决方案:
- 首先用
检查您的PHP版本,在我的情况下,版本是php7.4,因此安装了必要的驱动程序,并安装了PHP-v
apt get install php7.4-pgsql
- 最后重新启动PHP服务器