简体   繁体   中英

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());

2:

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

But Not working Help please. Thank You

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

为什么不尝试这样:$ connection = mysqli_connect('127.0.0.1','root','',database_name)或die('something');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM