星期二, 十月 09, 2007

数据库连接与 /etc/hosts 设置

上次数据库出问题后更换了主机,但之后时常出现"Can not connect to database"的错误,考虑了若干中可能,但最有效的还是先查看系统日志 /var/log/message:
Oct  9 10:49:31 shopex mysqld: gethostby*.getanswer: asked for "210.0.168.192.in-addr.arpa IN PTR", got type "A"
...
Oct 9 10:49:32 shopex mysqld: gethostby*.getanswer: asked for "210.0.168.192.in-addr.arpa IN PTR", got type "A"
这说明是地址解析的问题,mysqld 中设置了反向 DNS 解析。一般只需要在 /etc/hosts 中增加相应的记录即可:
192.168.0.210   www

没有评论: