所以我有一个基本的Laravel 5.4应用程序。我运行php artisan make:auth来搭建身份验证系统。我能够迁移users表,没有问题
Migrated: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_100000_create_password_resets_table但是,当我尝试注册它时,抛出了SQL can't connect错误
SQLSTATE[HY000] [2002] Connection refused (SQL: select count(*) as aggregate from `users` where `email` = email@email.com)如果我能够成功地迁移表,这怎么可能发生呢?即使在registrion方法抛出这个错误之后,我仍然能够回滚迁移:
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版本无关
发布于 2017-10-03 03:13:06
您的问题出在.env文件中,您应该检查未指定用户名或密码的.env文件,以便从database.php获取homestead
检查您的.env的DB部分
DB_CONNECTION=mysql
DB_HOST=my ip //localhost
DB_PORT=3306
DB_DATABASE=myDBname
DB_USERNAME=root
DB_PASSWORD=my passhttps://stackoverflow.com/questions/41865185
复制相似问题