Access MySQL via PHP script on another server?

anta40

Registered
Jan 19, 2018
1
0
1
Jakarta, Indonesia
cPanel Access Level
Website Owner
Let's say I have a VPS with a public IP 123.123.100.101
I put a PHP script in there which is going to read a table from my blog database (say
the database name is h123084_wp702)

So, first I have to grant remote access, right?


Then the issue is to update my connection code. I have this:
PHP:
<?php

$host ="";
$user ="";
$pass ="";
$db    ="h123084_wp702";
$con = mysqli_connect($host, $user, $pass, $db) or die("Cannot connect to database...");

?>
What are the correct values of $host, $user, and $pass?

I cannot update my original post with attachments, because it was detected as spam :(
So here are the pictures, anyway.
cp1.jpg
cp2.jpg
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,911
2,234
363
Hello,

The host is the domain name or IP address of the remote server that hosts the MySQL database, and the username/password fields are for the database username and the password for that database username.

Thank you.