[英]Lavavel migrate not work in a LAMP AWS instance with MySQL RDS DB --> SQLSTATE[HY000] [2002] Connection timed out
I have setup an EC2 aws instance with Apache, PHP 7.2, Git, Composer and a RDS MySQL 5.7 database. I have setup an EC2 aws instance with Apache, PHP 7.2, Git, Composer and a RDS MySQL 5.7 database.
I followed the AWS official tutorials and others like Deploying and Scaling a Laravel Web App on AWS — Part 1 but I can't finish the laravel project installation.我遵循了 AWS 官方教程和其他教程,例如Deploying and Scaling a Laravel Web App on AWS — 第 1 部分,但我无法完成 laravel 项目的安装。 Using ssh terminal connection, in time to migrate (sudo php artisan migrate), I get the response:使用 ssh 终端连接,及时迁移(sudo php artisan migrate),我得到响应:
Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] Connection timed out (SQL: select * from information_schema.tables where table_schema = database_name and table_name = migrations) Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] Connection timed out (SQL: select * from information_schema.tables where table_schema = database_name and table_name = migrations)
When I try this same connection using MySQL WorkBench, I can connect, create or drop a table for example.例如,当我使用 MySQL WorkBench 尝试相同的连接时,我可以连接、创建或删除表。
I think the.env file or config/database.php are properly set, but I can't explain why I get this error.我认为 .env 文件或 config/database.php 设置正确,但我无法解释为什么会出现此错误。 Any help please?请问有什么帮助吗? Thanks谢谢
Seeing as this is a connection issue:看到这是一个连接问题:
Between your EC2 instance and the RDS MySQL database: you may have to add a rule to your security group allowing the standard MySQL port.在您的 EC2 实例和 RDS MySQL 数据库之间:您可能必须向您的安全组添加一条规则,以允许标准 MySQL 端口。 If you've made changes to the Network Access Control List attached to the subnet that your EC2 instance is in, you'll also want to modify the NACL to allow inbound AND outbound traffic from the instance to the RDS database.如果您更改了附加到您的 EC2 实例所在子网的网络访问控制列表,您还需要修改 NACL 以允许从实例到 RDS 数据库的入站和出站流量。
Between your RDS instance and Workbench: Check the security group on the Database (not the EC2 instance's security group)在您的 RDS 实例和 Workbench 之间:检查数据库上的安全组(不是 EC2 实例的安全组)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.