With the following code I can connect to mysql:
mysql_connect(\"localhost\",\"username\",\"\");
But if I change localhost to 127.0.0.
Do you have more than 1 mysql servers installed/running on your system? If so, please specify the port number of the mysql server you are trying to access like 127.0.0.1:3306,127.0.0.1:8889 etc.
If you do not know whether there are any other mysql server instances running on your system also, please specify the port.