Home Ask Login Register

Developers Planet

Your answer is one click away!

Jay February 2016

connect to mysql database using php on different port

my connection string is:

    $connection = mysql_connect("localhost", "root", "") or die("Could Not Connect to DB: ".mysql_error());

but on my computer i have installed IIS server first so localhost:80 is reserved by it so I changed my port to 8080 changing httpd.conf file in apache folder.

Now what should I change in connection string to connect to my database. I am using XAMPP .

should I tried writing these: 1:

  $connection = mysql_connect("localhost:8080", "root", "") or  die("Could Not Connect to DB: ".mysql_error());


$connection = mysql_connect("localhost,8080", "root", "") or    die("Could Not Connect to DB: ".mysql_error());

But Not working Help please. Thank You


mohsen alizadeh February 2016

Default port number which Mysql server uses is 3306 Web servers default port is 80

Web server and Mysql server are independent.

Do not change your api to connect to your mysql

anubhav deshwal February 2016

Why don't you try this: $connection=mysqli_connect('','root','',database_name)or die('something');

Post Status

Asked in February 2016
Viewed 3,549 times
Voted 13
Answered 2 times


Leave an answer

Quote of the day: live life