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.
– rray
just checked mo postgres and there is a root user
– Shaolin Fantastic