{"id":10301,"date":"2026-06-05T09:13:20","date_gmt":"2026-06-05T03:43:20","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=10301"},"modified":"2026-06-05T09:13:42","modified_gmt":"2026-06-05T03:43:42","slug":"configuring-mysql-to-listen-on-a-private-ip-address","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/configuring-mysql-to-listen-on-a-private-ip-address\/","title":{"rendered":"Configuring MySQL to Listen on a Private IP Address"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In environments where application servers and database servers communicate over a private network, configuring MySQL to listen on a private IP address improves security and reduces exposure to public networks. This approach ensures that database connections are restricted to trusted internal systems while maintaining application connectivity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide outlines the process of configuring MySQL to accept connections through a private IP address and updating dependent applications accordingly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before proceeding, ensure that:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Root or administrative access to the MySQL server is available.<\/li>\n\n\n\n<li>The server has a configured private IP address.<\/li>\n\n\n\n<li>MySQL service is installed and running.<\/li>\n\n\n\n<li>Firewall rules allow MySQL traffic on port 3306 between the required servers.<\/li>\n\n\n\n<li>Access to application .env configuration files and Docker environments is available.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Implementation<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Review Existing MySQL Users<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">List the existing MySQL users configured with localhost and identify the users that require remote access through the private network.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT User, Host FROM mysql.user;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Create Equivalent Users for Remote Access<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create corresponding MySQL users using % as the host value and assign the same privileges.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE USER 'dbuser'@'%' IDENTIFIED BY 'password';\n\nGRANT ALL PRIVILEGES ON database_name.* TO 'dbuser'@'%';\n\nFLUSH PRIVILEGES;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Update the MySQL Bind Address<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Open the MySQL configuration file and modify the bind address to the server&#8217;s private IP address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bind-address =<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save the configuration after making the changes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Restart the MySQL Service<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Restart the MySQL service to apply the updated configuration.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl restart mysql\n\nor\n\nsystemctl restart mysqld<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Verify that the service is running successfully.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Update Application database&#8217;s .env configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For applications running inside Docker containers, update the database host value in the application&#8217;s .env file to use the new private IP address of the MySQL server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DB_HOST=\n\nDB_PORT=3306<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save the configuration after updating the database host.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Redeploy or Restart Docker Containers<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Redeploy or restart the Docker containers so that the updated database configuration is loaded.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 7: Validate Database Connectivity<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Test the application and confirm that database operations are functioning correctly through the private network connection.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ensure that:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Applications can connect to the database.<\/li>\n\n\n\n<li>No authentication errors are reported.<\/li>\n\n\n\n<li>Database-dependent services operate as expected.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Configuring MySQL to listen on a private IP address improves security by restricting database access to trusted internal networks. After updating MySQL user permissions and bind settings, it is important to update any dependent Docker-based applications with the new database host information and redeploy the containers to ensure uninterrupted connectivity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In environments where application servers and database servers communicate over a private network, configuring MySQL to listen on a [&hellip;]<\/p>\n","protected":false},"author":531,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-10301","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-2G9","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/10301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/531"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=10301"}],"version-history":[{"count":5,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/10301\/revisions"}],"predecessor-version":[{"id":10306,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/10301\/revisions\/10306"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=10301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=10301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=10301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}