我试图使用php artisan migrate
通过Laravel将数据库迁移到AWS RDS,但是,它给了我这个错误:
Illuminate\Database\QueryException : SQLSTATE[08006] [7] could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "xxxxxxxxx.xxxxxxxxx.us-east-2.rds.amazonaws.com" (xx.xxx.xxx.xxx) and accepting
TCP/IP connections on port 5432? (SQL: select * from information_schema.tables where table_schema = public and table_name = migrations)
我对此问题进行了一些研究,发现我需要创建一个新的安全组以允许从我的IP地址进行访问,并且添加了一个新规则,其类型为“ PostgreSQL”及其默认值设置,但我的IP在“源”列中。而且我仍然无法迁移数据库(与上述错误相同)
这是.env文件中的数据库配置,也许某些字段错误?
DB_CONNECTION=pgsql
DB_HOST=xxxxxxxxx.xxxxxxxxx.us-east-2.rds.amazonaws.com
DB_PORT=5432
DB_DATABASE=xxxx
DB_USERNAME=xxxx
DB_PASSWORD=xxxx
我将不胜感激!
答案 0 :(得分:0)
您是否检查服务器是否可以访问RDS?
ssh进入您的服务器,然后运行
psql -h xxxxxxxxx.xxxxxxxxx.us-east-2.rds.amazonaws.com -d mydb -U myuser