【发布时间】:2014-10-09 08:37:28
【问题描述】:
我正在尝试通过 Laravel 连接 PostgreSQL 数据库以进行 php artisan 迁移,但似乎没有被定向,因为它正在读取 MySQL 的数据库名称。
以下是来自 database.php 的命令:
'connections' => array(
'sqlite' => array(
'driver' => 'sqlite',
'database' => __DIR__.'/../database/production.sqlite',
'prefix' => '',
),
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
'pgsql' => array(
'driver' => 'pgsql',
'host' => 'localhost',
'database' => 'postgres',
'username' => 'postgres',
'password' => 'root',
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
),
'sqlsrv' => array(
'driver' => 'sqlsrv',
'host' => 'localhost',
'database' => 'database',
'username' => 'root',
'password' => '',
'prefix' => '',
),
),
如果我删除 MySQL 路径,我会得到:
[InvalidArgumentException]
Database [mysql] not configured.
编辑: 尝试执行 php artisan migrate 时,我收到“PDOException:找不到驱动程序”。我正在使用 WAMP,我在 Win8.1 中。使用 PostgreSQL 作为数据库。
编辑: 已经尝试了一系列替代解决方案,但我仍然应该解决这个问题。 在 Apache、WAMP(来自 php 文件夹)和 PostgreSQL 中检查了
php.ini 文件。 extension_dir 是正确的 -> extension_dir = "c:/wamp/bin/php/php5.5.12/ext/"
extension=pdo_pgsql.dll 和 extension=pgsql.dll 未注释。
在“系统变量”中完成PATH 技巧并重新启动。没有机会。
感谢到目前为止的帮助。
这些是我的驱动程序 php_pdo_driver.h 和 php_pdo.h 来自 C:\Program Files (x86)\PostgreSQL\EnterpriseDB-ApachePHP\php\SDK\include\ext\pdo
来自 phpinfo 的信息:
PHP 版本 5.5.12
编译器 MSVC11 (Visual C++ 2012) 配置命令 cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" “--enable-debug-pack” “--without-mssql” “--without-pdo-mssql” “--没有 pi3web” “--with-pdo-oci=C:\php-sdk\oracle\x64\instantclient10\sdk,shared” “--with-oci8=C:\php-sdk\oracle\x64\instantclient10\sdk,shared” “--with-oci8-11g=C:\php-sdk\oracle\x64\instantclient11\sdk,shared” “--enable-object-out-dir=../obj/” “--enable-com-dotnet=shared” "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo"
【问题讨论】:
-
如果数据库是您的数据库名称,那么您使用保留字作为数据库名称
-
我的 PostgreSQL 数据库名称是 postgres,如代码所示^
-
太棒了,完全误读了您的帖子。您确定 laravel 正在尝试默认连接到您的 postgres 数据库吗?
-
我不这么认为:(默认情况下它似乎正在尝试连接到 MySQL,我想弄清楚如何。猜猜用户 sgt 想出来了。非常感谢,我的朋友。
标签: php database postgresql laravel syntax-error