Error trying to migrate bd from Laravel to Postgresql

Asked

Viewed 3,317 times

2

I’m using Postgresql "5.4.*"

Using Mysql, after the php artisan migrate tdo ok.

But now I need to use Postgresql in the project, but after changing the DB:

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=laravel-api
DB_USERNAME=postgres
DB_PASSWORD=1234

Give me this mistake:

D:\wamp64\www\laravel\laravel-api>php artisan migrate

  [Illuminate\Database\QueryException]
  could not find driver (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations)


  [PDOException]
  could not find driver

Detail, the environment is Windows.

  • Enabled the postgres extension in php.ini?

  • Put the database configuration file database.php complete.

  • I am using Postgresql "5.4. *" --> There is no such version of Postgresql. The latest is 11.1.

1 answer

4


To enable the PDO extension for postgres in PHP, the first step is to find the following line in php.ini and remove the ;

;extension=php_pdo_pgsql.dll

Then restart apache. You can check that the installation has occurred correctly with apache phpinfo(), should show something like:

inserir a descrição da imagem aqui

Another way to see which PDO drivers are installed is to call static method PDO::getAvailableDrivers()

<?php
echo "<pre>";
print_r(PDO::getAvailableDrivers());

Exit:

Array
(
    [0] => mysql
    [1] => pgsql
    [2] => sqlite
)
  • Vlw, it worked out!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.