3

所以我有一个几乎是基本的 Laravel 5.4 应用程序。我跑去php artisan make:auth搭建身份验证系统。我能够迁移用户表没问题

Migrated: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_100000_create_password_resets_table

但是,当我尝试注册时,会引发 SQL 无法连接错误

SQLSTATE[HY000] [2002] Connection refused (SQL: select count(*) as aggregate from `users` where `email` = email@email.com)

如果我能够成功迁移表,怎么会发生这种情况?即使在注册方法引发该错误之后,我仍然能够回滚迁移:

Rolled back: 2014_10_12_100000_create_password_resets_table
Rolled back: 2014_10_12_000000_create_users_table 

并重新迁移表:

Migrated: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_100000_create_password_resets_table

所以我知道 PostgreSQL 服务器已启动并正在运行。

小更新 Laravel 5.3 也发生了同样的问题,因此它与最近发布的 5.4 无关

4

1 回答 1

0

您的问题出在.env文件中,您应该检查.env未指定用户名或密码的文件,以便homesteaddatabase.php

检查你.env的数据库部分

DB_CONNECTION=mysql
DB_HOST=my ip //localhost
DB_PORT=3306
DB_DATABASE=myDBname
DB_USERNAME=root
DB_PASSWORD=my pass
于 2017-10-02T19:13:06.307 回答