Laravel: Error [PDOException]: Driver not found in PostgreSQL
P粉722409996
P粉722409996 2023-07-31 18:16:43
0
2
565

Translate: "I'm trying to connect to a PostgreSQL database via Laravel in order to execute the php artisan migrate command, but it doesn't seem to be successful because it's reading the MySQL database name.

;The following are the commands in 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' => '', ), ),

If I remove the path to MySQL, I get:

[InvalidArgumentException] Database [mysql] not configured.



Translate: "Edit: I encountered a 'PDOException: could not find driver' error when trying to execute the php artisan migrate command. I'm using WAMP and on Windows 8.1. The database is using PostgreSQL."< /strong>




EDIT: Translate: "I have tried a series of alternative solutions but the problem is still not resolved. Have checked php.ini in Apache, WAMP (from php folder) and PostgreSQL File.extension_dir is set correctly as shown below -> extension_dir = "c:/wamp/bin/php/php5.5.12/ext/". extension=pdo_pgsql.dll and extension=pgsql.dll have been uncommented.< br />
Have set the PATH in the 'System Variables' and restarted the computer. But still no success.

Thanks for the help so far.

This is my driver php_pdo_driver.h and php_pdo.h located in C:Program Files (x86)PostgreSQLEnterpriseDB-ApachePHPphpSDKincludeextpdo

From phpinfo Information obtained:


Translate: "PHP version 5.5.12

Compiler MSVC11 (Visual C 2012) configuration command cscript /nologo configure.js "--enable-snapshot-build" "- -disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:php- sdkoraclex64instantclient10sdk,shared" "--with-oci8=C:php-sdkoraclex64instantclient10sdk,shared" "--with-oci8-11g=C:php-sdkoraclex64instantclient11sdk,shared" "--enable-object-out-dir=../ obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo""

< ;br />


P粉722409996
P粉722409996

reply all (2)
P粉043295337

"For PDOException: could not find driver for MySQL error, if it is a Debian-based operating system

sudo apt-get -y install php5-mysql
    P粉037450467

    Translate: "Be sure to configure the 'default' key in app/config/database.php.

    For PostgreSQL, the configuration should be 'default' => 'postgres'.

    If you receive a [PDOException] could not find driver error, check that you have the correct PHP extensions installed. You need to install and enable pdo_pgsql.so and pgsql.so. How to install these extensions varies by operating system.

    For Windows, the pgsql extension should already be pre-downloaded with the official PHP distribution. Just edit your php.ini file and uncomment the following lines extension=pdo_pgsql.so and extension=pgsql.so.

    Also, in php.ini, make sure extension_dir is set to the correct directory. It should be a folder named extensions or ext or similar in your PHP installation directory.

    Finally, add libpq. dll from C:\wamp\bin\php\php5.*\ to C:\wamp\bin\apache*\bin and restart all services through the WampServer interface.

    If the exception still occurs, you You may need to add PostgreSQL's \bin directory to your PATH environment variable."

    1. System Properties -> Advanced tab -> Environment Variables
    2. In the 'System Variables' group in the lower half of the window, scroll and find the PATH entry.
    3. Select it and click Edit.
    4. At the end of the existing entry, enter the full path to your postgres bin directory. The bin folder should be located in the root of your postgres installation directory.
    5. Restart any open command prompts, or just to be sure, restart your computer.

    This should solve any problem. For more information see:

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!