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 ('mysql: host = 127.0.0.1; dbname = cars', 'root', 'root_password', 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' = > 'car', 'username' => 'root', 'password' => 'root_password', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' = > 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' => 'root_password', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name '=>' mysql ')) in ConnectionFactory.php line 60 ('driver' = 'mysql', 'host' => '127.0.0.1', 'database' => 'cars', 'username' => 'root' , 'password' => 'root_password', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name '=>' mysql ')) in ConnectionFactory.php line 49 ('driver' = 'mysql', 'host' => '127.0.0.1', 'database' => 'cars', 'username' => 'root' , 'password' => 'root_password', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false) mysql ') in DatabaseManager.php line 175
My .env file looks like this:
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=carros
DB_USERNAME=root
DB_PASSWORD=senha_do_root
And my database file looks 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',
],