In the production environment, the database connection is very fast, as expected. However, when using the same configuration on localhost, it takes around 10 seconds to connect. I've tried several solutions, but none have worked so far. I tested connecting to a different server, and the connection is established quickly. But when connecting from localhost, it still takes time. The MySQL port is open, and I've restarted the server, but the issue persists.
Database connection taking too long to connect in localhost
- Best Answerset by aaP_imdadullahbabu01
Hello, do you mean to connect to the database remotely? Do you want to turn off DNS verification for mysql?
skip-name-resolve
aaPanel_Kern
Yes, I mean remote database, using the database credentials like (hostname, username, password, database_name) in php code to build the connection, by turning off DNS verification will this solve the problem, if yes how should I do this?
- Edited
Great, This one is works, Thank you