{"id":7949,"date":"2022-10-07T10:14:47","date_gmt":"2022-10-07T10:14:47","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=ht_kb&#038;p=7949"},"modified":"2024-06-07T13:02:47","modified_gmt":"2024-06-07T13:02:47","password":"","slug":"how-to-enable-remote-mysql-access-on-a-vps","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/","title":{"rendered":"How To Enable Remote MySQL Access on a VPS"},"content":{"rendered":"\n<p>By default, MySQL does not allow users to connect to it remotely. This means, if you have a database server running MySQL, you cannot access it from your computer or any other computer directly unless it MySQL is configured to allow this. To access, you have to login to that server via SSH and run your MySQL connection commands there.<\/p>\n\n\n\n<p>This article will help us know how to configure the MySQL server to allow remote connections<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>You should have a server that already has MySQL or MariaDB installed<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Procedure<\/h2>\n\n\n\n<p>1.Login to your server via SSH<\/p>\n\n\n\n<p>2.Using your favorite editor, open the MySQL configuration file. <\/p>\n\n\n\n<p>By default, this is located under <strong>\/etc\/mysql\/mysql.conf.d\/mysqld.cnf <\/strong>on Debian based operating systems e.g Ubuntu and  <strong>\/etc\/my.cnf <\/strong>on Redhat based operating systems eg Centos<\/p>\n\n\n\n<p>3. Look for bind-address on the file and change the IP so that its as follows. <\/p>\n\n\n\n<p><strong>bind-address  = 0.0.0.0<\/strong><\/p>\n\n\n\n<p>If there is no such line, simply add the following somewhere under <strong>[mysqld] <\/strong>section<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"153\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-1024x153.png\" alt=\"\" class=\"wp-image-7950\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-1024x153.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-300x45.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-768x114.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-50x7.png 50w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-920x137.png 920w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-600x89.png 600w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-320x48.png 320w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24.png 1329w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>4. Save and quit the editor then <strong>restart<\/strong> MySQL service<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ systemctl restart mysqld<\/pre>\n\n\n\n<p>After you perform the above, you have successfully enabled  remote access on your account.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Other Considerations<\/h2>\n\n\n\n<p>However, it may be necessary to perform some additional steps to be able to access the database remotely:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Allow MySQL traffic on your firewall<\/h3>\n\n\n\n<p>If you use Ubuntu\/Debian, you may be using a firewall called UFW. To allow traffic on UFW, run the command below. <\/p>\n\n\n\n<p>$ <code>sudo ufw allow 3306\/tcp<\/code><\/p>\n\n\n\n<p>If using Redhat\/Centos, you may be using firewalld. Use the command below to allow traffic<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo firewall-cmd --zone=public --add-port=3306\/tcp<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Create a user who with remote access privileges<\/h3>\n\n\n\n<p>When you create database users initially, you may have created them to access the database from <strong>localhost<\/strong> or <strong>127.0.0.1<\/strong> only.<\/p>\n\n\n\n<p>You need to create users and allow access from any host as follows<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mysql > create user 'username_here'@'%' identified by 'password_here';\nmysql > grant all privileges on database_name_here.* to 'username_here'@'%';\nmysql > flush privileges;<\/pre>\n\n\n\n<p>Replace <strong>username_here<\/strong> with the actual username, <strong>password_here<\/strong> with the password and <strong>database_name_here<\/strong> with the database name the user should access.<\/p>\n\n\n\n<p>The <strong>%<\/strong> sign shows the user is being granted permissions to access from any IP address.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, MySQL does not allow users to connect to it remotely. This means, if you have a database server running MySQL, you cannot access it from your computer or any other computer directly unless it MySQL is configured to allow this. To access, you have to login to that server via SSH and run [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[],"doc_tag":[],"class_list":["post-7949","docs","type-docs","status-publish","hentry"],"year_month":"2026-06","word_count":373,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"w m","author_nicename":"wm","author_url":"https:\/\/truehost.com\/support\/author\/wm\/"},"doc_category_info":[],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How To Enable Remote MySQL Access on a VPS -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Enable Remote MySQL Access on a VPS -\" \/>\n<meta property=\"og:description\" content=\"By default, MySQL does not allow users to connect to it remotely. This means, if you have a database server running MySQL, you cannot access it from your computer or any other computer directly unless it MySQL is configured to allow this. To access, you have to login to that server via SSH and run [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-07T13:02:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-1024x153.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-enable-remote-mysql-access-on-a-vps\\\/\",\"url\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-enable-remote-mysql-access-on-a-vps\\\/\",\"name\":\"How To Enable Remote MySQL Access on a VPS -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-enable-remote-mysql-access-on-a-vps\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-enable-remote-mysql-access-on-a-vps\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2022\\\/10\\\/Screenshot-from-2022-10-07-12-52-24-1024x153.png\",\"datePublished\":\"2022-10-07T10:14:47+00:00\",\"dateModified\":\"2024-06-07T13:02:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-enable-remote-mysql-access-on-a-vps\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-enable-remote-mysql-access-on-a-vps\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-enable-remote-mysql-access-on-a-vps\\\/#primaryimage\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2022\\\/10\\\/Screenshot-from-2022-10-07-12-52-24-1024x153.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2022\\\/10\\\/Screenshot-from-2022-10-07-12-52-24-1024x153.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/knowledge-base\\\/how-to-enable-remote-mysql-access-on-a-vps\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Enable Remote MySQL Access on a VPS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Enable Remote MySQL Access on a VPS -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/","og_locale":"en_US","og_type":"article","og_title":"How To Enable Remote MySQL Access on a VPS -","og_description":"By default, MySQL does not allow users to connect to it remotely. This means, if you have a database server running MySQL, you cannot access it from your computer or any other computer directly unless it MySQL is configured to allow this. To access, you have to login to that server via SSH and run [&hellip;]","og_url":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/","article_modified_time":"2024-06-07T13:02:47+00:00","og_image":[{"url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-1024x153.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/","url":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/","name":"How To Enable Remote MySQL Access on a VPS -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/#primaryimage"},"image":{"@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/#primaryimage"},"thumbnailUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-1024x153.png","datePublished":"2022-10-07T10:14:47+00:00","dateModified":"2024-06-07T13:02:47+00:00","breadcrumb":{"@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/#primaryimage","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-1024x153.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2022\/10\/Screenshot-from-2022-10-07-12-52-24-1024x153.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.truehost.com\/support\/knowledge-base\/how-to-enable-remote-mysql-access-on-a-vps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"How To Enable Remote MySQL Access on a VPS"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/7949","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=7949"}],"version-history":[{"count":3,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/7949\/revisions"}],"predecessor-version":[{"id":7953,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/7949\/revisions\/7953"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=7949"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=7949"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=7949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}