Could I have my php scripts on server A and connect to the MySQL database on server B?
If yes, how it would be done? Thanks in advance
It's simple: all of the techniques mentioned above may seem complicated.
Let's say you have a database hosted on server B and a website on server A (with an IP address of 192.234.12.1).
On cPanel, you need to whitelist the IP address of server B. Next, create a new user with sufficient privileges in the database (let's name this user "test").
Finally, configure this user as test@192.234.12.1.