You should be warned. Amazingly, in 10 years of PHP/MySQL
development work I never hit this issue in the manner I did this
week. There are several reasons that PHP could not be able to
connect to MySQL. The MySQL daemon could be down. It could be an
authentication problem. Or, perhas the entire server is offline.
The last one there is the one I want to talk about.
In your php.ini you will find a value called
mysql.connect_timeout. In the PHP ext/mysql it defaults to 60
seconds. Likewise, the php.ini has the same value. As far as I
can tell, this timeout only comes in to play when the server is
completely offline. If the server is up, but mysqld is not, the
server refuses the connection immediately. I suppose if the
server was under high load it could be used as well.
Well, IMO, 60 seconds is way to long to wait on a connection to
the database for a web application. We had a server offline and
expected the …
[Read more]