I have installed Laravel 5 successfully and changed MySQL credentials in database.php file in config directory to \'
mysql\' => [
\'driver\'
Match the .env file and the config.php file with your username and password and your hostname in the database settings.if they are not equal,relation will not connect.
Try to checkout the ".env" file in your root directory. It will be a hidden file. Correct these values.
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Instead of using this
DB_HOST=localhost
DB_DATABASE=wdcollect
DB_USERNAME=root
DB_PASSWORD=
USE this
DB_HOST=localhost
DB_DATABASE=wdcollect
DB_USERNAME=root
DB_PASSWORD=''
You need to run these two commands
php artisan cache:clear
php artisan config:cache
Jeez! Thanks to umair.ashfr answer here below, I finally hit the nail with an issue that was eating my neurons.
I had a password like DB_PASSWORD=ffjdh5#fgr on my .env, and MySQL connection was gracefully saying that "SQLSTATE[HY000] [1045] Access denied for user...", no matter what flavor of php artisan I was trying to run.
The problem was that "#" sign inside the password. BEWARE! That means the start of a comment, thus my password was silently truncated! The solution is to declare password like DB_PASSWORD="ffjdh5#fgr"
Regards
None of these worked for me when I deployed my website online on shared hosting, below is what I did that worked.
In the .env
file, I changed
DB_HOST=127.0.0.1
to
DB_HOST=localhost
and viola, it worked well as expected.