mysql_connect and mysql_pconnect running VERY slow?
After doing much research I found a lot of people claiming to have solved the problem to a slow mysql_connect. Unfortunately none of the suggestions worked for me. I tried updated MySql Server, PHP, etc. I tried adding lined to My.ini and playing with the php.ini buffer information. Finally I found the solution.
On your server’s host file (normally found in c:\windows\system32\drivers\etc\hosts), add your server’s IP address (in my case it was the WAN IP) and map it to your server’s machine name. For example:
123.456.123.456 server_name
My sql connect times went from 5-6 seconds down to less then 1 second!