Connect to Database via Another Server.

I am trying to connect to the database on my server (Website A) via another website hosted elsewhere (Website B).

Using the following on Website B.

$servername = "IP ADDRESS OF Website A";
$username = "";
$password = "";
$dbname = "";

$conn = new mysqli($servername, $username, $password, $dbname );

All the information is correct but still not allowing me to connect.

In the CyberPanel backend I have added the ‘Website B IP Address’

Am I missing a step?

Thanks
Adam

I’ve got the same issue. Did you manage to solve it?
Website A on old server A.
Clone of Website A & Databased onto Cyberpanel Server B.
Adding IP from Server A to “Allow Remote Access on following IP” for the database on Server B.
Changed configs of website A on server A to point to database on Server B.
Issue: Cannot connect to database even though database, user, password & host are correct.

Any idea?
thanks

Look at Cyberpanel Firewall Settings.

And config mysql Server to allow external connections like described here:

(it´s only a suggestion - didn´t test it on my own on cyberpanel, but out of the box mysql blocks external access by it´s own confgi)