2
votes

Why can't I migrate to my database? The .env configuration is correct and I created a model in addition to creating the database in phpMyAdmin.

php artisan migrate

When I run the migrate command I get the following error:

Illuminate\Database\QueryException : SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)

2
please share .env file code hereUdhav Sarvaiya
can you please share your .evn file DB config dataShailendra Gupta
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=dbblog DB_USERNAME=dbblog DB_PASSWORD=dbblogJohn Cris Mañabo

2 Answers

1
votes

This error basically comes from the after changes in the .env file. Whenever we change the DB_DATABASE, DB_USERNAME and DB_PASSWORD in .env file, we need to clear the cache.

After completion of .env edit, enter this command in your terminal for clear cache: php artisan config:cache

Also, If you are using the PHP's default web server (eg. php artisan serve) you need to restart your server after changing your .env file values.

0
votes

very easy my friend go to your .env file and edit this line to your password

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306
//here
DB_DATABASE=homestead

DB_USERNAME=homestead

DB_PASSWORD=secret

//to here

and do

php artisan migrate