简体   繁体   中英

PHP Mysql iis VPS - connect from remote server

I have:
A shared hosting account with host X,
A VPS on host Y,
AND XAMPP to my home pc.


I have IIS on my vps and installed mysql and phpmyadmin (they work great). I want to be able to access my database on my VPS FROM my Shared hosting account.
I use this script on my local PC using XAMMP and i connect successfully to my REMOTE VPS database .

$db_host = 'mydomain.com';
$db_user = 'admin';
$db_password = 'db_pass';
$db_name = 'db_name';
$db_port = '3306';

$mysqli = new mysqli($db_host, $db_user, $db_password, $db_name, $db_port);
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " .     $mysqli->connect_error . mysqli_error();
} else { echo 'OK';}

When i use the same script on my Shared Host , it will give me this error:

Warning: mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on 'mydomain.com' (110)

Any idea on how to solve this?
I also tried using the VPS ip instead of mydomain.com with the same results.
Also user admin has all privileges in MYSQL @ %

For some specific shared hosting, such as GoDaddy or HostPapa, you need to allow the IP address to be able to connect to the database. To do so, you can go the cPanel and go under Remote MySQL

Documentation:

  1. GoDaddy
  2. cPanel Forum

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