为什么连接到MySQL服务器这么慢? [英] Why is connecting to MySQL server so slow?
问题描述
我使用JDBC连接到MySQL.当它位于localhost:3306
时,一切正常.
I use JDBC to connect to MySQL. When it’s at localhost:3306
, everything is OK.
但是,当我将应用程序移动到Intranet中的另一台计算机上并使用<Intranet-IP>:3306
连接到MySQL数据库时,大约需要1分钟才能成功连接到MySQL.这是怎么回事?
But when I move my application to another computer in the intranet, and use <Intranet-IP>:3306
to connect to the MySQL database, it takes about 1 minute to connect to MySQL successfully. What’s up with this?
推荐答案
这可能是DNS问题.您可以通过在配置文件中以--skip-name-resolve
选项启动mysqld
来禁用DNS主机名查找.
Well it could be a DNS problem. You can disable DNS host name lookups by starting mysqld
with the --skip-name-resolve
option in the configuration file.
在这里阅读更多详细信息: http://dev. mysql.com/doc/refman/5.0/en/host-cache.html
Read here for more details: http://dev.mysql.com/doc/refman/5.0/en/host-cache.html
这篇关于为什么连接到MySQL服务器这么慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!