{"id":18422,"date":"2026-09-29T23:51:15","date_gmt":"2026-09-29T20:51:15","guid":{"rendered":"https:\/\/www.hyyat.com\/knowledgebase\/enable-remote-mysql\/"},"modified":"2026-11-22T18:52:56","modified_gmt":"2026-11-22T15:52:56","password":"","slug":"enable-remote-mysql","status":"publish","type":"docs","link":"https:\/\/www.hyyat.com\/en\/knowledgebase\/enable-remote-mysql\/","title":{"rendered":"Connecting to a MySQL Database from Outside the Server: WHM, cPanel Remote Database Access and the Firewall"},"content":{"rendered":"<div class=\"hkb\" dir=\"ltr\">\n<div class=\"hkb-tldr\"><b>How it works<\/b>Three layers must allow the connection: the account owner adds the outside machine\u2019s IP in <b>Remote Database Access<\/b> in cPanel, port <b>3306<\/b> is opened in the firewall for that address only, and (optionally) you add it in <b>Manage Database Access Hosts<\/b> in WHM for every account.<\/div>\n<div class=\"hy-vid\"><div style=\"width: 1280px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-18422-1\" width=\"1280\" height=\"720\" poster=\"https:\/\/www.hyyat.com\/zasogooh\/2026\/11\/hyyat-srv-remotesql-en.jpg\" preload=\"none\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/www.hyyat.com\/zasogooh\/2026\/11\/hyyat-srv-remotesql-en.mp4?_=1\" \/><a href=\"https:\/\/www.hyyat.com\/zasogooh\/2026\/11\/hyyat-srv-remotesql-en.mp4\">https:\/\/www.hyyat.com\/zasogooh\/2026\/11\/hyyat-srv-remotesql-en.mp4<\/a><\/video><\/div><\/div>\n<p>Sometimes accounting software on an office PC, or an app on another server, needs to read the site\u2019s database directly. MySQL refuses any connection that does not come from the server itself by default, which is good for security. This guide opens the door for one specific address only.<\/p>\n<h2>Layer one: the account\u2019s cPanel<\/h2>\n<p>In the database owner\u2019s cPanel, open <b>Remote Database Access<\/b> under Databases, enter the outside machine\u2019s IP and click Add Host. This is what gives the database user permission to connect from that address.<\/p>\n<h2>Layer two: WHM (for all accounts)<\/h2>\n<p class=\"hkb-path\"><code>WHM \u203a Database Services \u203a Manage Database Access Hosts<\/code><\/p>\n<figure class=\"hkb-fig\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.hyyat.com\/zasogooh\/2026\/11\/hkb-sv-w-dbhosts.webp\" alt=\"WHM Manage Database Access Hosts for adding addresses allowed to connect\" width=\"800\" height=\"457\" loading=\"lazy\" \/><\/figure>\n<p>Enter one address per line and Save. As the page itself says, this is not enough on its own: the account owner must add the address in Remote Database Access, or you click the link at the bottom to apply the addresses to every account.<\/p>\n<h2>Layer three: the firewall<\/h2>\n<p>Open port 3306 to one address, not the world. In CSF, add a line to <code>\/etc\/csf\/csf.allow<\/code>:<\/p>\n<pre class=\"hkb-code\">tcp|in|d=3306|s=203.0.113.5   # accounting PC\ncsf -r<\/pre>\n<p>If your provider has an external firewall, allow the same address there. Ports are covered in <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/open-port-csf-firewall-whm\/\">opening a port in CSF<\/a>.<\/p>\n<div class=\"hkb-note warn\">Never put % (any host) in Remote Database Access, and never open 3306 in TCP_IN for everyone. A database open to the world is a permanent target for password guessing.<\/div>\n<h2>Connection details to give the app<\/h2>\n<div class=\"hkb-tbl\">\n<table>\n<thead>\n<tr>\n<th>Field<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Host<\/td>\n<td>The server\u2019s IP or hostname, not localhost<\/td>\n<\/tr>\n<tr>\n<td>Port<\/td>\n<td>3306<\/td>\n<\/tr>\n<tr>\n<td>Database<\/td>\n<td>The full name with prefix, such as user_dbname<\/td>\n<\/tr>\n<tr>\n<td>User<\/td>\n<td>The full database user with prefix, not the cPanel user<\/td>\n<\/tr>\n<tr>\n<td>Password<\/td>\n<td>The database user\u2019s password<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2>A safer alternative: an SSH tunnel<\/h2>\n<p>Instead of opening 3306, the app can connect through an SSH tunnel: it connects to the server on the SSH port, then reaches the database locally. Tools such as HeidiSQL and DBeaver support this directly.<\/p>\n<h2>Connection errors<\/h2>\n<div class=\"hkb-tbl\">\n<table>\n<thead>\n<tr>\n<th>Message<\/th>\n<th>Likely cause<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>Host ... is not allowed to connect<\/code><\/td>\n<td>The address is not in Remote Database Access<\/td>\n<\/tr>\n<tr>\n<td><code>Can\u2019t connect ... (110)<\/code> or a timeout<\/td>\n<td>The port is closed in the firewall or at the provider<\/td>\n<\/tr>\n<tr>\n<td><code>Access denied for user<\/code><\/td>\n<td>Wrong username or password, or the prefix is missing<\/td>\n<\/tr>\n<tr>\n<td>Works, then stops<\/td>\n<td>The outside machine\u2019s IP changed (a home connection with a dynamic address)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h2>A full example: accounting software in the office<\/h2>\n<ol class=\"hkb-steps\">\n<li><b>Is the office IP fixed?<\/b> Ask the internet provider. If it changes, an SSH tunnel or VPN suits better than opening the port.<\/li>\n<li><b>The account owner adds the address<\/b> in Remote Database Access in cPanel.<\/li>\n<li><b>You open the port for that address<\/b> one line in csf.allow as above.<\/li>\n<li><b>Test from the office<\/b> <code>mysql -h server-address -u user_db -p<\/code>, or from the software itself.<\/li>\n<li><b>Document it<\/b> note why the port was opened and for which address, so you can close it when no longer needed.<\/li>\n<\/ol>\n<h2>Remote access questions<\/h2>\n<div class=\"hkb-faq\">\n<details>\n<summary>Can I allow a range of addresses?<\/summary>\n<p>Yes. Remote Database Access accepts a form such as 203.0.113.%, but keep the range as narrow as possible.<\/p>\n<\/details>\n<details>\n<summary>Is the connection encrypted?<\/summary>\n<p>Not by default. For sensitive data, use an SSH tunnel or an SSL connection if the app supports it.<\/p>\n<\/details>\n<details>\n<summary>Does this work on shared hosting?<\/summary>\n<p>Yes, through Remote Database Access in cPanel, provided the port is allowed on the server. Ask support if it does not work.<\/p>\n<\/details>\n<details>\n<summary>Does remote access affect site performance?<\/summary>\n<p>Heavy queries from the outside app use the same database resources, so watch them if they are large.<\/p>\n<\/details>\n<\/div>\n<div class=\"hkb-rel\"><b>Related guides<\/b><\/p>\n<ul>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/open-port-csf-firewall-whm\/\">Opening a Port in the CSF Firewall: From WHM or csf.conf, Plus the Common cPanel Ports<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/mysql-commands-ssh\/\">Basic MySQL Commands to Manage Databases over SSH<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/create-mysql-database-cpanel\/\">Create a MySQL Database and User in cPanel: With the Wizard or by Hand<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/upgrading-mysql-to-mariadb-on-a-cpanel-whm-server\/\">Upgrading MySQL to MariaDB on a cPanel\/whm server<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.hyyat.com\/en\/kb\/whm-cpanel-control-panels\/\">All WHM guides \u2192<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>How it worksThree layers must allow the connection: the account owner adds the outside machine\u2019s IP in Remote Database Access in cPanel, port 3306 is opened in the firewall for that address only, and (optionally) you add it in Manage Database Access Hosts in WHM for every account. Sometimes accounting software on an office PC, [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":21261,"comment_status":"open","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"_templately_pack_id":"","_templately_imported_at":"","_templately_source":"","_templately_import_session_id":"","footnotes":""},"doc_category":[2734],"doc_tag":[],"class_list":["post-18422","docs","type-docs","status-publish","has-post-thumbnail","hentry","doc_category-whm-cpanel-control-panels"],"year_month":"2026-11","word_count":667,"total_views":"3","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"ahmed fathy","author_nicename":"ahmed-fathy","author_url":"https:\/\/www.hyyat.com\/en\/author\/ahmed-fathy\/"},"doc_category_info":[{"term_name":"WHM\/cPanel","term_url":"https:\/\/www.hyyat.com\/en\/kb\/whm-cpanel-control-panels\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs\/18422","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/comments?post=18422"}],"version-history":[{"count":0,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs\/18422\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/media\/21261"}],"wp:attachment":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/media?parent=18422"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/doc_category?post=18422"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/doc_tag?post=18422"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}