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)
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.