![]() |
|
How to Allow Remote Connection to a MySQL Database Server on RHEL or CentOS - Printable Version +- My Board (https://ellohost.com/forum) +-- Forum: Tutoriel EN (https://ellohost.com/forum/forumdisplay.php?fid=8) +--- Forum: Others (https://ellohost.com/forum/forumdisplay.php?fid=20) +--- Thread: How to Allow Remote Connection to a MySQL Database Server on RHEL or CentOS (/showthread.php?tid=14) |
How to Allow Remote Connection to a MySQL Database Server on RHEL or CentOS - aaron - 07-17-2023 How to Allow Remote Connection to a MySQL Database Server on RHEL or CentOSBefore starting with this guide, ensure that you have access to the following:
Note that you’ll need to establish an SSH connection if the server is outside your data center by using PuTTY on Windows or the built-in terminal shell on Linux and macOS. 1. Changing the MySQL Server Configuration FileThe first step is to make the remote MySQL server listen for external connections by adding an extra option to the configuration file. To do this, log in to your server as the root user and run the following command to determine the location of the MySQL configuration file: The output should look like this: Then, open and edit the MySQL config file using the nano editor: Once the file opens, locate the line that contains Remember to replace If there is a line containing After editing the file, save it by pressing CTRL+X or COMMAND+X if you are on Mac. For changes to take effect, restart the MySQL service by running the following command: 2. Opening The Required MySQL PortThe default MySQL port for external connections is 3306. If you have configured a firewall service on the MySQL server, you need to allow traffic through this specific port. If iptables is your default firewall tool, execute the following command to open port 3306 for unrestricted traffic: Note that the command above will allow remote access from all IP addresses on the internet through the MySQL port. Alternatively, you can grant access to a remote user from one specified IP address with the following command: Remember to change Once you’re finished, save the iptables configuration by entering: The response will look like this: Now the server will allow remote connections to your MySQL service. Try running the MySQL server to establish a connection from your remote system by typing the command below: Replace The output will look similar to this: Connection to mysql_server_ip 3306 port [tcp/mysql] succeeded! How to Allow Remote Connections to MySQL Database Server on hPanelYou can connect to the MySQL server remotely by allowing an IP address on your account’s side. To start the process, log in to your hPanel and navigate to Databases -> Remote MySQL. On the Remote MySQL page, type the IP address of your remote server in the IP (IPv4 or IPv6) field or tick the Any Host box to connect from any IP. Then, select the Database that you want to access remotely. Once you’re done, click Create. Remember that remote connections also require a MySQL user to use their MySQL server hostname – you can find the hostname at the top of the same page. ConclusionIn this tutorial, we’ve gone over how to connect to the MySQL server from a remote host or grant access to a remote MySQL user. Here’s a quick recap of the steps required to accept remote connection from remote hosts on an RHEL or CentOS server:
Good luck. Be sure to leave a comment below if you have any questions. |