简体   繁体   English

Lavavel 迁移在具有 MySQL RDS DB 的 LAMP AWS 实例中不起作用 --> SQLSTATE[HY000] [2002] 连接超时

[英]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.

相关问题 SQLSTATE [HY000] [2002]连接超时 - SQLSTATE[HY000] [2002] Connection timed out 远程服务器SQLSTATE [HY000] [2002]连接超时 - Remote Server SQLSTATE[HY000] [2002] Connection timed out 连接错误 - SQLSTATE[HY000] [2002] 操作超时 - Connection Error - SQLSTATE[HY000] [2002] Operation timed out SQLSTATE[HY000] [2002] 操作超时 - SQLSTATE[HY000] [2002] Operation timed out Laravel 迁移 SQLSTATE[HY000] [2002] 连接被拒绝 - Laravel Migrate SQLSTATE[HY000] [2002] Connection refused SQLSTATE [HY000] [2002]访问远程数据库时连接超时,日志显示尝试连接 - SQLSTATE[HY000] [2002] Connection timed out while accessing remote database, logs show a connection was attempted PDOException SQLSTATE[HY000] [2002] 本地计算机上的连接超时 - PDOException SQLSTATE[HY000] [2002] Connection timed out on my local computer 尝试连接到Google Cloud SQL时出现消息“ SQLSTATE [HY000] [2002]连接超时”的PDOException - PDOException' with message 'SQLSTATE[HY000] [2002] Connection timed out' when trying to connect to google cloud sql Symfony 4 worker使用doctrine无法正常工作:SQLSTATE [HY000] [2002] Connection超时 - Symfony 4 worker using doctrine not working properly : SQLSTATE[HY000] [2002] Connection timed out Laravel SQLSTATE [HY000] [2002]连接被拒绝| 锻造 AWS - Laravel SQLSTATE[HY000] [2002] Connection refused | Forge | AWS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM