php artisan migrate - SQLSTATE[HY000] [1045] Access denied for user 'laravel'@'localhost'
I had the same problem with my plesk ubuntu 18.04 remote server. In your .env file put double quotes around your database password and username then run php artisan config:clear
and php artisan cache:clear
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=dbname
DB_USERNAME="xyz"
DB_PASSWORD="123"
I had never come across this problem before.
You don't have a user named 'laravel'. You should change the DB_USERNAME to the one you're actually using to access your DB. Mostly it's root by default so the changes in .env should be
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
If you are trying to run this command with homestead, you need to make sure you change the values of the following environmental variables within the .env
file to:
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
After you have changed the values, make sure to run the following two commands before you do anything else:
php artisan config:clear
php artisan cache:clear