John Cris Mañabo
John Cris Mañabo

Reputation: 230

I Can't Migrate to Database

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)

Upvotes: 1

Views: 224

Answers (2)

RYOK
RYOK

Reputation: 473

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

Upvotes: 0

Udhav Sarvaiya
Udhav Sarvaiya

Reputation: 10061

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.

Upvotes: 1

Related Questions