MySQL connection timed out: error SQLSTATE[HY000] [2002] Connection timed out

I've searched a bunch on the internet, but they're all wrong

Later, I realized that it was actually a setting problem.

When your code is deployed to the server, your mysql host value should be

127.0.0.1

instead of your server ip

Otherwise, an error will be reported.

In fact, when your code enters the server, mysql and the code are equivalent to the same ip, so use 127.0.0.1 instead of the server ip

remember! No need to change any configuration issues.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325041668&siteId=291194637