easy-swoole / easyswoole

swoole,easyswoole,swoole framework
https://www.easyswoole.com/
Apache License 2.0
4.75k stars 511 forks source link

crontab下mysql 2002 #191

Closed luzzhong closed 5 years ago

luzzhong commented 5 years ago

HTTP请求业务正常,但是在定时任务下却报错2002

SQLSTATE[HY000] [2002] Connection timed out

image

kiss291323003 commented 5 years ago

暂时无法复现

wangchengyue commented 3 years ago

我今天在连接数据库的时候也遇到这个问题...好奇怪啊... 就是服务启动以后,请求api尝试连接数据库的时候出现: [2021-07-06 12:25:07][trigger][error]:[SQLSTATE[HY000] [2002] Connection timed out at file:/home/chengyue.wang/4sdemouiadmin/vendor/easyswoole/orm/src/Db/MysqlPool.php line:22] 而在本地开发环境没有问题,到了服务器上,连接RDS的时候出现了上述的问题...

wangchengyue commented 3 years ago

承接上文,我通过调试发现,mysql的config是本地开发环境的config,所以会出现上述的问题,mysql的配置在两处:

  1. dev.php
  2. EasySwooleEvent.php 后者好像会把前者的配置给覆盖掉,有点意思... 如果再遇到这种情况,请仔细检查配置文件,是否多处修改不同步的问题导致的...