How to Allow Remote Connection to MySQL Server in cPanel/WHM Server?

Remote MySQL connections are disabled on WHM/cPanel servers by default to prevent potential security risks to MySQL servers. Remote MySQL connections can be allowed from Web Host Manager (WHM) or through cPanel (for specific databases created under that cPanel account). This guide will be applicable to VPS and dedicated server customers as remote MySQL connection is not allowed in shared hosting by hosting providers. Before you allow remote connection to MySQL server in cPanel/WHM server, please ensure to open port 3306 on your server firewall.

Enable Remote MySQL from WHM

  1. Login to WHM.
  2. Locate theSQL Services section and click Additional MySQL Access Hosts link.allow remote mysql from WHM server

At the next screen, enter an IP address or host(s) you wish to grant remote MySQL access and click the Save button. To activate these settings for all cPanel accounts, click the Save at the bottom. Now, a remote connection is activated in the WHM panel. Each cPanel account that wants to use a remote connection needs to activate this.

Enable Remote MySQL from the cPanel

  1. Login to cPanel.
  2. Locate the Databases section and locate Remote MySQL option and click on it.remote mysql from cpanel
  3. In the next screen, enter the hostname or IP address, you need to grant remote MySQL access and click the Save button. If your IP address changes regularly, you can use a wildcard by using the % symbol. It will add all IP addresses in that range. For example; if you want to list IP addresses ranging from 192.168.3.1 to 192.168.3.255, you can add an IP address as 192.168.3.%.
    remote mysql from cpanel adding host

Above steps will allow remote connection to MySQL Server from cPanel/WHM server.

NOTE: Below are the additional steps that need to be taken if you cannot connect to the MySQL server after enabling Remote MySQL from WHM.

Sometimes, after enabling MySQL remote connections, you might not be able to connect to the MySQL server remotely. This happens as the MySQL server is bound on localhost (127.0.0.1). To fix this issue, you need to make the following changes in the MySQL configuration file (my.conf).

  1. Login to the MySQL server (where MySQL server is installed) and edit my.cnf file using a text editor such as a vi editor. Usually, my.cnf file is located at /etc/mysql/my.cnf or at /etc/my.cnf.
    # vi /etc/my.cnf
  2. Once the file is open, locate the line containing skip-networking and ensure it is commented as below.
    # skip-networking
  3. Now locate the line containing bind-address and comment it out as follows.
    # bind-address = 127.0.0.1
  4. Save and Close the file and restart the MySQL server using the below command.
    # /etc/init.d/mysql restart // Debian & Ubuntu Linux
    # /etc/init.d/mysqld restart // CentOS & Fedora Linux

You should now be able to connect to the MySQL server remotely.

Add a Comment

Your email address will not be published. Required fields are marked *