PDOException (1045)If you got this error message, mean Laravel can not access you database with your configuration.
SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)
First of all, what you should do is to check up your configuration in database.php which located in this directory:
your_project_root/app/config/database.php
For my case, I use mysql as my database so check the 'mysql' array value in database.php file. (change text in red to your text)
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'testing',
'username' => 'user',
'password' => '123',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
If the error message still appear if you comfirm your database configuration are correct, you should check is the environnement value "$env" in your project changed the as local or development.
(file path to check environement value:)
your_project_root/bootstrap/start.php
You should visit the "database.php " in "config/local" folder since Laravel would load the config files within this folder if you have set envirnment as development.
path :
your_project_root/app/config/local/database.php
for my case, I changed array value of "'mysql'" from
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'homestead',
'username' => 'homestead',
'password' => 'secret',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
to resolved this Access denied for user 'homestead'@'localhost' problem. (change text in red to your text)
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'testing',
'username' => 'user',
'password' => '123',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
Reference:
https://laracasts.com/forum/?p=1804-access-denied-for-user-homestead-localhost/0
No comments :
Post a Comment