{"id":22475,"date":"2023-10-15T04:31:48","date_gmt":"2023-10-15T04:31:48","guid":{"rendered":"https:\/\/linuxways.net\/?p=22475"},"modified":"2023-10-19T02:14:37","modified_gmt":"2023-10-19T02:14:37","slug":"allow-remote-connections-mysql","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/scripting\/allow-remote-connections-mysql\/","title":{"rendered":"How to Allow Remote Connections to MySQL"},"content":{"rendered":"<div id=\"wpbody\">\nMySQL is a famous free-to-use\u00a0relational database administration system due to its reliability, scalability, and user-friendliness. MySQL is set up by default to allow connections exclusively from the localhost, limiting the access from the database server to the local machine. There are times, however, when remote connections to the MySQL server are required, particularly when numerous users need to access the database from various places. Enabling remote connections can help the teams cooperate more effectively by allowing for continuous communication.<\/p>\n<p>Users can connect to the database server from multiple locations by setting MySQL to allow the remote connections. This promotes productivity and cooperation. This adaptability enables the enterprises and organizations to take use of MySQL&#8217;s capabilities in dispersed contexts. This allows collaborative data management and improves the overall operational efficiency.<\/p>\n<h2><strong>Installing MySQL in Linux<\/strong><\/h2>\n<p>To install MySQL on our Linux system, refresh or update the package index first.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> apt update<\/div><\/div>\n<p>Setup the MySQL server software. We can select either the standard MySQL server or the community edition which is also known as MySQL Server CE.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> mysql-server<\/div><\/div>\n<p>The user has to set a password for the MySQL during the installation.<\/p>\n<p>The MySQL service should begin soon after the installation is complete. We can check the status if it is active or not by typing the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> systemctl status mysql<\/div><\/div>\n<p>Somehow, if it is not started, we can start it by typing the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> systemctl start mysql<\/div><\/div>\n<h2><strong>Changing the Bind-Address IP<\/strong><\/h2>\n<p>After completing the whole installation process, run this command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>mysql<span class=\"sy0\">\/<\/span>mysql.conf.d<span class=\"sy0\">\/<\/span>mysqld.cnf<\/div><\/div>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;height:100%;\"><div class=\"bash codecolorer\"><span class=\"br0\">&#91;<\/span>mysqld<span class=\"br0\">&#93;<\/span><br \/>\n<br \/>\n<span class=\"co0\">#<\/span><br \/>\n<br \/>\n<span class=\"co0\"># * Basic Settings<\/span><br \/>\n<br \/>\n<span class=\"co0\">#<\/span><br \/>\n<br \/>\nuser = mysql<br \/>\n<br \/>\n<span class=\"co0\"># pid-file = \/var\/run\/mysqld\/mysqld.pid<\/span><br \/>\n<br \/>\n<span class=\"co0\"># socket = \/var\/run\/mysqld\/mysqld.sock<\/span><br \/>\n<br \/>\n<span class=\"co0\"># port = 4405<\/span><br \/>\n<br \/>\n<span class=\"co0\"># datadir = \/var\/lib\/mysql<\/span><br \/>\n<br \/>\n<span class=\"sy0\">**<\/span> many <span class=\"kw2\">more<\/span> outputs <span class=\"sy0\">**<\/span><br \/>\n<br \/>\n<span class=\"co0\"># tmpdir = \/tmp<\/span><br \/>\n<br \/>\n<span class=\"co0\">#<\/span><br \/>\n<br \/>\nbind-address = 127.0.0.1<br \/>\n<br \/>\nmysqlx-bind-address = 127.0.0.1<br \/>\n<br \/>\n<span class=\"co0\">#<\/span><\/div><\/div>\n<p>The server only seeks for local connections if this value is set to 127.0.0.1. The previous directive needs to be changed to contain an external IP address. To help with fixing the problems, we may set this command to a global IP address such as *,::, or 0.0.0.0:<\/p>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;height:100%;\"><div class=\"bash codecolorer\"><span class=\"br0\">&#91;<\/span>mysqld<span class=\"br0\">&#93;<\/span><br \/>\n<br \/>\n<span class=\"co0\">#<\/span><br \/>\n<br \/>\n<span class=\"co0\"># * Basic Settings<\/span><br \/>\n<br \/>\n<span class=\"co0\">#<\/span><br \/>\n<br \/>\nuser = mysql<br \/>\n<br \/>\n<span class=\"co0\"># pid-file = \/var\/run\/mysqld\/mysqld.pid<\/span><br \/>\n<br \/>\n<span class=\"co0\"># socket = \/var\/run\/mysqld\/mysqld.sock<\/span><br \/>\n<br \/>\n<span class=\"co0\"># port = 4405<\/span><br \/>\n<br \/>\n<span class=\"co0\"># datadir = \/var\/lib\/mysql<\/span><br \/>\n<br \/>\n<span class=\"sy0\">**<\/span> \u2026\u2026.. many <span class=\"kw2\">more<\/span> outputs \u2026\u2026\u2026<span class=\"sy0\">**<\/span><br \/>\n<br \/>\n. Ref https:<span class=\"sy0\">\/\/<\/span>dev.mysql.com<span class=\"sy0\">\/<\/span>doc<span class=\"sy0\">\/<\/span>refman<span class=\"sy0\">\/<\/span><span class=\"nu0\">8.0<\/span><span class=\"sy0\">\/<\/span>en<span class=\"sy0\">\/<\/span>server-system-variables.html<span class=\"co0\">#sysvar_tmpdir<\/span><br \/>\n<br \/>\n<span class=\"co0\"># tmpdir = \/tmp<\/span><br \/>\n<br \/>\nbind-address = 0.0.0.0<br \/>\n<br \/>\nmysqlx-bind-address = 127.0.0.1<br \/>\n<br \/>\n<span class=\"co0\">#<\/span><\/div><\/div>\n<p>After that, just do the following steps:<\/p>\n<ul>\n<li><strong>Save the Changes:<\/strong> To save the modifications that we made, press the following key combination: \u201cCTRL + X\u201d. This command tells Nano that we want to exit the editor.<\/li>\n<li><strong>Confirm the Saved Changes:<\/strong> After pressing \u201cCTRL + X\u201d, Nano will ask, &#8220;Save modified buffer?&#8221; and there will be two options: \u201cY\u201d or \u201cN\u201d. We need to type \u201cY\u201d.<\/li>\n<li><strong>Specify the File Name:<\/strong> After confirming the saved changes, Nano presents the option to specify the file name if we made changes to the original file. If we want to keep the same file name, simply press \u201cENTER\u201d on our keyboard.<\/li>\n<li><strong>Exit Nano:<\/strong> Once we saved the changes, Nano will exit and we&#8217;ll return to the command line interface or terminal.<\/li>\n<\/ul>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>Remote MySQL connections are required in a variety of scenarios involving dispersed applications, remote development, and collaborative database management. By following the processes that are outlined in this extensive guide, we may securely modify MySQL server&#8217;s settings and enable the remote access which allows us to fully utilize MySQL&#8217;s capabilities while ensuring the security of our database.<\/p>","protected":false},"excerpt":{"rendered":"<p>Guide on securely modifying MySQL server&#8217;s settings and enabling the remote access to fully utilize MySQL&#8217;s capabilities while ensuring the database\u2019s security.<\/p>","protected":false},"author":111,"featured_media":22480,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[168],"tags":[],"class_list":["post-22475","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/22475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/111"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=22475"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/22475\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/22480"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=22475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=22475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=22475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}