I have a php script on my server which is called by my client app to log some information into a remote mysql server. The scripts works fine, but occasionally (only occasionally) the script fails to connect.
I set up the scripts to send me error mails whenever a connection is failed, and I got the following error from mysql_error():
Unknown MySQL server host '[myDBhostaddress]' (2)
Where [myDBhostaddress] is, of course, a correct address of my db host. For the majority of time the script works, thus I don't think the address or log in credential is wrong.
I try to reproduce the problem but no luck. I can log in to my mysql server from my local machine, my server machine. Connecting from command line works, test php scripts works, and manually invoking those scripts which sent me error mails also work!
I'm pretty confused by this problem now, as I don't know how I can deal with it. I don't even know the cause of the problem. Would it be the mysql server overloaded? Would it be an attack by intruders?
And if it helps, my php scripts are living in Amazon's EC2, and mysql server in Amazon's RDS.