How can I connect to MySQL on a WAMP server?


Question

This might be ridiculously easy for you but I've been struggling with this for an hour... :(

<?php
$connect = mysql_connect("localhost:8080", "root", "mypassword");
echo($connect);?>

This is the code that I'm trying to run - you can see that I'm using 8080 as my port number and, of course, I have HTML codes as well.

However, it gives me the following error messages whenever I try to open the PHP file:

Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone away in C:\wamp\www\php_sandbox\index.php on line 2

Warning: mysql_connect() [function.mysql-connect]: Error while reading greeting packet. PID=4932 in C:\wamp\www\php_sandbox\index.php on line 2

Warning: mysql_connect() [function.mysql-connect]: MySQL server has gone away in C:\wamp\www\php_sandbox\index.php on line 2

I don't know... what's wrong with this? Is it because of the port number?

1
13
10/18/2011 12:04:44 PM

Accepted Answer

Change localhost:8080 to localhost:3306.

24
3/16/2010 11:49:47 PM

Try opening Port 3306, and using that in the connection string not 8080.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon