The MySQL database server stands as a foundational element for countless content management systems and e-commerce applications globally. It is instrumental in facilitating secure and dependable data storage and retrieval, which in turn enables the functionality of dynamic and personalized websites. cPanel & WHM offers a comprehensive solution for MySQL management, streamlining many routine database tasks encountered in web hosting environments while simultaneously providing web hosts with granular control when necessary. While it is common practice for websites and cPanel's MySQL instance to reside on the same server, there are distinct advantages to separating these components. Utilizing a remote MySQL database, hosted on a separate server, can be a highly beneficial strategy in various scenarios.

Several compelling reasons might lead you to deploy a remote MySQL server:

  • Offload Database Workloads: By separating the database from the webserver, you can significantly improve the performance of both busy websites and the database itself, ensuring smoother operation under heavy loads.
  • Specialized Database Hosting: This approach allows for the use of a server specifically optimized and configured for database hosting, leveraging specialized hardware and software for maximum efficiency and reliability.
  • Centralized Management: Consolidate database management across multiple servers, simplifying administration and maintenance tasks from a single point of control.
  • Enhanced Security: Isolate the database from servers that are directly exposed to public IP addresses, thereby reducing the attack surface and enhancing overall security posture.

It is crucial to understand that exposing the MySQL server directly to the internet and allowing connections from untrusted IP addresses constitutes an improper and highly insecure method for achieving remote database access. This practice invariably introduces a critical security vulnerability that malicious actors frequently exploit to compromise systems and steal sensitive data. This article will guide you through the correct and secure approach, demonstrating how to leverage cPanel to properly configure MySQL, enabling it to accept connections exclusively from designated web applications hosted on separate, authorized servers.

Using a Remote Database to Host Your Site’s Data

To successfully follow the steps outlined in this tutorial, ensure you have the following prerequisites:

  • A server equipped with cPanel & WHM installed, which will serve as your designated remote database server.
  • The specific IP address or domain name of the database server, along with the necessary cPanel authentication credentials, and the MySQL username and password.
  • A separate server dedicated to hosting your web applications. While the method detailed here is compatible with manual site installation and configuration, integrating it with cPanel offers a significantly faster and more convenient experience.

Initially, we will detail the process for cPanel users to configure a remote MySQL database. Following this, we will explore WHM’s powerful MySQL Profile management tools, which offer broader administrative control.

Configuring a Remote MySQL Database with cPanel

Begin by logging into cPanel on the server hosting the MySQL instance you intend to provide remote access to. From the main page menu, locate and select the Remote MySQL® tool.

cPanel Menu Remote MySQL

Within the Add Access Host form, input either the domain name or the IP address of the server where your web application is hosted. For scenarios requiring access from a range of IP addresses, you have the option to use a wildcard character (%), such as 192.68.0.%, to permit multiple IP addresses. When employing a wildcard, it is imperative to restrict its scope strictly to addresses under your direct control or those you are absolutely certain pose no security threat.

cPanel Remote MySQL Manager

After entering the necessary information, click the Add Host button. This action instructs cPanel to configure the MySQL database to accept incoming requests from the specified remote site. The subsequent step involves configuring your web application to utilize this newly accessible remote database. The exact procedure will vary depending on the specific application you are using. For instance, with a freshly installed WordPress site, you would first establish the database using cPanel’s MySQL® Database Wizard. Following database creation, you would then modify the WordPress site’s wp-config.php file to include the database name, authentication credentials, and the remote server’s domain name or IP address.

define( 'DB_NAME', 'wp_database' );
define( 'DB_USER', 'user' );
define( 'DB_PASSWORD', 'a-secure-password' );
define( 'DB_HOST', '203.0.113.0' );

Adding MySQL Access Hosts in WHM

System administrators possess the capability to configure MySQL to accept incoming connections from web applications hosted on other servers. It is important to note key distinctions between configuring remote database access through cPanel versus WHM:

  • Global Application: Hosts configured in WHM are universally applied across all cPanel user accounts and their associated MySQL users on the server.
  • Administrator Control: cPanel users are unable to permanently remove access hosts that have been added by system administrators within WHM.

To grant remote hosts access to MySQL databases, log into WHM and navigate to the Additional MySQL Access Hosts section, found under SQL Services in the sidebar menu.

cPanel Additional Access Hosts

Here, enter the domain names or IP addresses of the remote hosts that require permission to connect to the server’s databases, then click Save. Once configured, proceed to update your web applications with the appropriate IP address and authentication credentials to begin utilizing the databases on the server, as detailed in the preceding section. For more in-depth information regarding database access hosts, we recommend consulting the official feature documentation page.

Managing MySQL Profiles in WHM

Beyond direct configuration of remote databases, WHM empowers server administrators to establish and manage MySQL profiles. These profiles serve as a centralized mechanism within WHM for defining and connecting to various remote database servers, including dedicated MySQL servers, other cPanel & WHM instances, and even cloud-based solutions like Amazon’s Relational Database™ Service. Notably, the local machine’s default database configuration itself is managed through such a profile.

It's important to recognize that only one MySQL profile can be active at any given moment. To create a new profile, access WHM and proceed to Manage MySQL® Profiles, located within the SQL Services section of the sidebar menu.

cPanel WHM MySQL Profiles

WHM simplifies the process by being able to automatically log into the specified server, create a new MySQL superuser for database management, and meticulously configure MySQL settings. Alternatively, if your MySQL installation is already set up with a superuser, you can readily provide those existing credentials.

cPanel New MySQL Profile

Upon activation of a new profile, all subsequent new databases will be provisioned on the designated remote server. However, it is crucial to understand that existing databases will not be automatically migrated; manual data transfer will be required to move them to the new remote location.

In summary, cPanel & WHM offers unparalleled flexibility and robust control for web hosts and their clients in the realm of MySQL database configuration and management. This powerful platform provides several key advantages:

  • Optimized Local Hosting: Benefit from outstanding, ready-to-use default settings for hosting MySQL databases directly on the local server.
  • Seamless Remote Integration: Effortlessly configure databases for websites and e-commerce stores hosted on remote servers, simplifying complex setups.
  • Comprehensive Administrator Tools: Leverage advanced system administrator tools that grant complete command over MySQL installations and precise control over the location of database hosting.
Was this answer helpful? 0 Users Found This Useful (0 Votes)