操作系统:Ubuntu16.10
服务器: Nginx
DB: PostgreSQL 9.5.4
Laravel 5.4
尝试执行我的数据库迁移,但是php artisan migrate抛出以下错误:
照明\数据库\QueryException找不到驱动程序:( select *来自information_schema.tables,其中tables_schema =用户名和table_name =迁移)
然后是第二条消息
PDOException 找不到司机
我做了以下工作:
当前,当我运行php -i时,我获得的PDO部分的输出是
PDO支持=>启用 PDO驱动程序=> pgsql
pdo_pgsql截面产量
PostgreSQL(libpq)版本=>9.5.4 模块版本=>7.0.15-0ubuntu0.16.10.4
而pgsql部分返回
PostgreSQL(libpq)版本= 9.5.4 PostgreSQL(libpq) => PostgreSQL 9.5.4 on x86_64-pc-linux-gnu,由gcc编译(Ubuntu6.1.1-11ubuntu12) 6.1.1 20160805,64位多字节字符支持=>启用 启用SSL支持=> 活动持久链接=> 0 活动链接=> 0
但尽管如此,还是会犯同样的错误。我认为这可能是权限问题,但是以root或www-data的形式运行命令也有相同的结果。
发布于 2019-09-24 11:54:09
您应该安装pdo
sudo apt upgrade
sudo apt install php-pgsql发布于 2019-07-18 20:40:48
我也经历过同样的情况,试一试下面的顺序,
1) install the postgre extensions for php, those are:
php-(YOUR_VERSION)-pgsql, and php-pgsql.
2) enable pgsql extensions in your php.ini file, basically,
uncomment the the extensions.
3) restart the apache server(or nginx).
4) check that extensions are enable using phpinfo() or any else tool.
5) set a password for (in instance) the postgres user in postgreSQL
server, this is a very important step.登录到psql shell:
sudo su - postgres
\password postgres输入密码并确认。
现在,设置.env文件,然后再试一次。
发布于 2017-03-12 16:23:24
您需要定义您的.env文件
在your.env文件中,您需要指定使用哪个数据库(MySQL、SQLite、Postgres),并指定DB用户名和密码。
APP_ENV=local
APP_KEY=base64:gqaCpjbEfukDr5As7EnrqRzi5PSho1rOS/q2H0E+HOs=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=YOUR_DB_NAME
DB_USERNAME=YOUR_USERNAME
DB_PASSWORD=YOUR_PASSWORD
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=在使用迁移时,运行这些命令总是很好的。
composer dump-autoload
php artisan cache:clear
php artisan view:clearhttps://stackoverflow.com/questions/42749465
复制相似问题