Connecting PHP Web Server to MySQL database server

BHPR26

Registered
May 1, 2019
2
0
1
Los Angeles
cPanel Access Level
Root Administrator
Hello,

I have a web server running PHP and another server for database in the same data center connecting on the same rack. What is the correct way to connect PHP to database server to reduce latency and increase the speed?

Webserver has Cpanel but should I have cpanel domain account for database as well? The database currently has WHM but no domains account for Cpanel

Thank you
 

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,754
315
363
Chesapeake, VA
cPanel Access Level
DataCenter Provider
You don't really NEED cpanel installed on the database server if all it is ever going to do is host databases, you can simply install your preferred version of MySQL on there and you can even have cPanel on the web server connect to it as an external database server using the Manage MySQL Profiles.

If they are in the same rack, if possible I would use a private network connection between them instead of using the public interface.
 

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,754
315
363
Chesapeake, VA
cPanel Access Level
DataCenter Provider
You would need to have two nice in the servers minimum and either a crossover cable installed between them or a separate switch set up to handle the private network
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,216
463
Hello @BHPR26,

Additionally, if it's just a single application that you want to use a remote MySQL database with, then you should not use WHM >> Manage MySQL Profiles to enable the remote MySQL server. That option is intended for administrators that want to store all of their MySQL databases on a remote server.

If you only want to host an individual MySQL database on a remote server, you'd simply setup the database on the remote server and use the remote server's IP address as the database host name in your PHP script's configuration file. Then, browse to cPanel >> Remote MySQL and add the MySQL server's IP address as an access host.

Thank you.