如何在Laravel Homestead中使用postgreSQL

Jam*_*ady 8 php postgresql laravel homestead

我可以迁移到我的家园.这是我的.env

DB_CONNECTION=pgsql
DB_HOST=localhost
DB_PORT=54320
DB_DATABASE=intern
DB_USERNAME=homestead
DB_PASSWORD=secret
Run Code Online (Sandbox Code Playgroud)

我做一个新的服务器在我的PostgreSQL的

server name = Homestead,  
username = homestead,  
password = secret.  
Run Code Online (Sandbox Code Playgroud)

然后,我做了迁移,并将所有表创建到我的数据库(server = homestead)
问题是,当我想在我的网站上登录时.它发生错误:

SQLSTATE[08006] [7] could not connect to server: Connection refused?  
Is the server running on host "localhost" (::1) and accepting?  
TCP/IP connections on port 54320??could not connect to server: Connection refused?  
Is the server running on host "localhost" (127.0.0.1) and accepting?  
TCP/IP connections on port 54320? (SQL: select * from "users" where "email" = user@gmail.com limit
Run Code Online (Sandbox Code Playgroud)

hut*_*tch 5

您的端口末尾有一个额外的0.更改DB_PORT=54320DB_PORT=5432

  • 你可以使用5432和54320,它只取决于你当前的机器.如果你在`guest`机器(宅基地)你应该使用端口5432,如果你在`host`机器上,你应该使用54320,否则它将无法工作.Laravel使用默认端口5432,因为它正在运行 - 默认情况下 - 在客户机内部,我很确定你必须将它保持到5432.你是否尝试将`DB_HOST`更改为`127.0.0.1`? (2认同)