Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 error SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

I have installed Laravel 5 successfully and changed MySQL credentials in database.php file in config directory to '

mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'wdcollect'),
            'username'  => env('DB_USERNAME', 'root'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

I don't want to use homestead and I have changed .env file to

APP_ENV=local
APP_DEBUG=true
APP_KEY=apLIzEMOgtc5BUxdT9WRLSvAoIIWO87N

DB_HOST=localhost
DB_DATABASE=wdcollect
DB_USERNAME=root
DB_PASSWORD=

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null

I don't understand that why it's saying that access denied for 'homestead'@'localhost'

like image 421
Ali Rehman Avatar asked Mar 31 '15 06:03

Ali Rehman


4 Answers

It's working now. I had to restart server. Thanks

like image 107
Ali Rehman Avatar answered Nov 13 '22 19:11

Ali Rehman


I was facing the same issue. Everything was fine but in

bootstrap/cache/config.php

always had the incomplete password. Upon digging further, realized that the password had '#' character in it and that was getting dropped. As '#' is used to mark a line as a comment.

like image 48
umair.ashfr Avatar answered Nov 13 '22 19:11

umair.ashfr


I spent hours on this :-( and finally, it was really easy to hack

BEFORE

DB_PASSWORD=#Root2020$

UPDATED

DB_PASSWORD="#Root2020$"

I think the problem was # in the password, that's why I had to write my password into quotation marks.

like image 32
zarpio Avatar answered Nov 13 '22 18:11

zarpio


You need to run these two commands

php artisan cache:clear
php artisan config:cache
like image 31
Syed Nazir Hussain Avatar answered Nov 13 '22 20:11

Syed Nazir Hussain