pgsql connection problems in Laravel 5.1

Asked

Viewed 1,903 times

0

I am trying to connect to the pgsql database by Laravel 5.1 but an error is appearing:

Pdoexception in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

--

in Connector.php line 55 at PDO->__Construct('mysql:host=127.0.0.1;dbname=cars', 'root', 'password_do_root', array('0', '2', '0', false, '0')) in Connector.php line 55 At Connector->createConnection('mysql:host=127.0.0.1;dbname=cars', array('driver' => 'mysql', 'host' => '127.0.0.1', 'database' => 'cars', 'username' => 'root', 'password' => 'senha_do_root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => ', 'Strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, '0')) in Mysqlconnector.php line 22 At Mysqlconnector->connect(array('driver' => 'mysql', 'host' => '127.0.0.1', 'database' => 'cars', 'username' => 'root', 'password' => 'senha_do_root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => ', 'Strict' => false, 'name' => 'mysql')) in Connectionfactory.php line 60 At Connectionfactory->createSingleConnection(array('driver' => 'mysql', 'host' => '127.0.0.1', 'database' => 'cars', 'username' => 'root', 'password' => 'senha_do_root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => ', 'Strict' => false, 'name' => 'mysql')) in Connectionfactory.php line 49 At Connectionfactory->make(array('driver' => 'mysql', 'host' => '127.0.0.1', 'database' => 'cars', 'username' => 'root', 'password' => 'senha_do_root', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'Strict' => false), 'mysql') in Databasemanager.php line 175

My file .env is like this:

    DB_HOST=127.0.0.1
    DB_PORT=5432
    DB_DATABASE=carros
    DB_USERNAME=root
    DB_PASSWORD=senha_do_root

And my file database is like this:

    'pgsql' => [
        'driver'   => 'pgsql',
        'host'     => env('DB_HOST', '127.0.0.1'),
        'port'      => '5432',
        'database' => env('DB_DATABASE', 'carros'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', 'senha_do_root'),
        'charset'  => 'utf8',
        'prefix'   => '',
        'schema'   => 'public',
    ],
  • Your dsn shows a connection to mysql, is there a root user in postgres? the default user is postgres.

  • just checked mo postgres and there is a root user

1 answer

2


maybe your config/database.php file, in the default attribute is like this:

'default' => env('DB_CONNECTION', 'mysql'),

positive case, switch to

'default' => env('DB_CONNECTION', 'pgsql'),
  • I really forgot to change but now I’ve got the error > Pdoexception in Connector.php line 55: could not find driver in Connector.php line 55 at PDO->_Construct('pgsql:host=127.0.0.1;dbname=cars', 'root', 'senha_do_root', array('0', '2', '0', false)) in Connector.php line 55

  • @BJJ look in your php.ini and check that the following lines are uncommented (without the ";" in front): extension=php_pdo_pgsql.dll extension=php_pgsql.dll

  • if commented, remove ";" from the front and restart apache.

  • It worked out Valeu!!

  • @BJJ please mark my reply as accepted answer. Thank you

Browser other questions tagged

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