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

I installed Laravel 5 successfully and changed the MySQL credentials in the database.php file in the configuration directory so that

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 do not want to use homestead and I changed the .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 do not understand why he said that access is denied for 'homestead' @ 'localhost'

+18
database php xampp laravel-5 localhost
source share
16 answers

Now it works. I had to restart the server. Thanks

+30
source share

You need to run these two commands

 php artisan cache:clear php artisan config:cache 
+13
source share

None of them worked for me when I hosted my website on the Internet on shared hosting, below is what I did, what worked.

In the .env file I changed

 DB_HOST=127.0.0.1 

to

 DB_HOST=localhost 

and viola, it worked well as expected.

+11
source share

if you use localhost and root before, your file will be cached

remove /bootstap/cache/config.php

+10
source share

I ran into the same problem. Everything was fine but in

bootstrap / cache / config.php

there was always an incomplete password. Rummaging further, I realized that the password has a "#" symbol, and this is reset. How "#" is used to mark a line as a comment.

+4
source share

This works for me:

 php artisan config:clear php artisan cache:clear php artisan config:cache 

Thank you

+3
source share

You do not need to set credentials in the database.php file. Enough if you have credentials in .env

If you can directly enter the database, this password should work. Perhaps you have a different environment than the "local" one, which is defined in this file. The test is performed using "php artisan env"

+2
source share

Try checking the ".env" file in the root directory. This will be a hidden file. Correct these values.

  DB_HOST=localhost DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret 
+2
source share

Please update the file below.

provider -.env - on line # 7

  DB_HOST=localhost DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret 

Instead of setting the user down, specify your database, username and password. This should work for you.

+1
source share

I encountered the same problem that I did

  1. PHP artisan cache: clear
  2. Php artisan configuration: cache

but found the same problem as mine

php artisan view: clear

Hope this will be helpful.

+1
source share

Pls.env Update File

  DB_HOST=localhost DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret 

After that restart the server

0
source share

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='' 
0
source share

I came up with this too ... then decide by putting the information in the database directly in "database.php" In your case, I would like to change the information like this

 mysql' => [ 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'wdcollect', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ], 

and do not forget to change the settings in config.inc XAMPP

 ['auth_type'] = 'config'; ['Servers'][$i]['user'] = 'root'; ['Servers'][$i]['password'] = ''; ['AllowNoPassword'] = true; 
0
source share

Map the .env file and the config.php file to your username and password and your hostname in the database settings. If they are not equal, communication will not be established.

0
source share

If you are on MAMP

Check your port number, usually this

Localhost host

Port 8889

Root user

Root password

Socket /Applications/MAMP/tmp/mysql/mysql.sock

0
source share

The .env file must have the same database name, username and password as in the mysql database, and check whether all permissions are granted to the user to access the database or not. I solved my problem by adding the cpanel username in front of the database name and username such as jumbo_admingo and jumbo_user1 respectively, where jumbo is my cpanel username and admingo is the database name that I created in mysql and user1 is the user who is granted access to the Admingo Database. THIS SOLVED MY PROBLEM.

0
source share

All Articles