[英]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.
.env 配置是正确的,除了在 phpMyAdmin 中创建数据库之外,我还创建了一个模型。
php artisan migrate
When I run the migrate command I get the following error:当我运行 migrate 命令时,我收到以下错误:
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)
Illuminate\\Database\\QueryException : SQLSTATE[HY000] [1045] 用户 'homestead'@'localhost' 的访问被拒绝(使用密码:YES)(SQL:从 information_schema.tables 中选择 *,其中 table_schema = homestead 和 table_name = migrations)
This error basically comes from the after changes in the .env file.此错误主要来自.env文件中的更改后。 Whenever we change the
DB_DATABASE
, DB_USERNAME
and DB_PASSWORD
in .env file, we need to clear the cache.每当我们更改.env文件中的
DB_DATABASE
、 DB_USERNAME
和DB_PASSWORD
时,我们都需要清除缓存。
After completion of .env edit, enter this command in your terminal for clear cache: php artisan config:cache
完成 .env 编辑后,在终端中输入此命令以清除缓存:
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.此外,如果您使用 PHP 的默认 Web 服务器(例如
php artisan serve
),则需要在更改 .env 文件值后重新启动服务器。
very easy my friend go to your .env file and edit this line to your password我的朋友很容易转到您的.env文件并将此行编辑为您的密码
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.