0
votes

I have connected to my database successfully as I was able to do all of my beginning migrations, users table and password reset etc.

It is my first time running php artisan make:auth and when I go to register a new user for the laravel application, I get this error.

SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) (SQL: select count(*) as aggregate from users where email = [email protected])

Here is my .env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=larabiz
DB_USERNAME=root
DB_PASSWORD=

The answer was quite simple but weird.

run php artisan make:auth. then run php artisan migrate. shutdown your server, restart the server, and then register your first user. This worked for me, so Laravel was not able to add users during registration, without first restarting the server. That took me 5 fresh Laravel installs and three hours of work! I was in tears :).

3
If this is linux, from the root directory, do grep -R homestead *. Or check all database.php config files to see where homestead may be hiding.aynber
It is a database connection error. Eventually bad username/password.halojoy
Your database username and password are different from what is mentioned in the error? Why is that?mohessaid
if username and password are incorrect how can migrate database as mentioned in the questionRahul Reghunath

3 Answers

1
votes

The answer was quite simple but weird.

run php artisan make:auth. then run php artisan migrate. shutdown your server, restart the server, and then register your first user. This worked for me, so Laravel was not able to add users during registration, without first restarting the server. That took me 5 fresh Laravel installs and three hours of work! I was in tears :).

0
votes

Did yout try to reload config ?

php artisan config:clear

or clear cache ?

php artisan cache:clear

0
votes

Go to config/database.php and under connections set the values for your connection manually.