Laravel 5: DB Issue
Actually I don't know where to post this issue, so I'm posting it here.... I installed laravel 5 which has inbuilt login/registration system. I decided to use mysql as default DB, I created a DB, login in http://localhost/phpmyadmin. Then I gave mysql configurations as:
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'Logintestfive'), 'username'=> env('DB_USERNAME', 'root'), 'password'=> env('DB_PASSWORD', 'manasa'), 'charset'=> 'utf-8', 'collation'=> 'utf-8_unicode_ci', prefix=> '', 'strict'=> false, ]
Then I accesses localhost:8080/auth/register, filled the form, submitted it and it returned the following errors:
PDOException in Connector.php line 47: SQLSTATE[28000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)
This is the stack trace:
in Connector.php line 47
at PDO->__construct('mysql:host=localhost;dbname=homestead', 'homestead', 'secret', array('0', '2', '0', false, '0')) in Connector.php line 47
at Connector->createConnection('mysql:host=localhost;dbname=homestead', array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, '0')) in MySqlConnector.php line 20
at MySqlConnector->connect(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in compiled.php line 10545
at ConnectionFactory->createSingleConnection(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in compiled.php line 10541
at ConnectionFactory->make(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'homestead', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false), 'mysql') in compiled.php line 10459
So I explored a bit, found out that .env file had basic configurations which pointed to homestead DB with relevant username and password. I replaced them with my DB, username and password like this:
APP_ENV=local APP_DEBUG=true APP_KEY=YOUR_KEY_HERE DB_HOST=localhost DB_DATABASE=loginlaravel5 DB_USERNAME=root DB_PASSWORD=manasa CACHE_DRIVER=file SESSION_DRIVER=file
But same problem repeated. So I used vim .env* and found that there were two files .env and .envexample. I edited .envexample according to my configurations. But no luck. How can I resolve this?
Ask on the forums please. This doesn't look like a bug in the core, more a misconfiguration.
same problem here.. if a fresh install has this issue then it's an issue ....
it happened to me too. Yes, This is an issue. It makes me feel Laravel 5 was not ready for production so far.
Yes, putting your database information directly in the source control such as config/database.php is never suitable for production environment.
I wonders if there the documentation hasn't explain this enough, or just lack of something else.
I have this problem to
I thought I had this issue and it turned out to be a mismatch in the configuration options. When copying across the configurations from 4.2 in database.php I inadvertently copied a ' at the end of the string. Perhaps triple check your settings.