skip to Main Content

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:

IlluminateDatabaseQueryException : 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

Answers


  1. 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.

    Login or Signup to reply.
  2. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search