Gice

Technology and General Blog

MySQL is a well known database administration procedure that has been readily available for years. Thanks to its flexibility and simple administration, lots of smaller developments to huge tasks use it.

In most scenarios, the MySQL server and the principal application are hosted on the exact device. So, MySQL listens for connections from the local device only. On the other hand, with the increase of dispersed systems in which the application and the database are hosted in independent servers, listening on localhost is not incredibly suitable.

If these types of instances happen, builders need to ensure that MySQL listens for remote connections or merely connections outside the house the community equipment. You can do this in two methods:

  • Modify the bind-tackle in the MySQL configuration file, or
  • Entry the MySQL server by means of an SSH tunnel.

In this tutorial, we will appear at how to edit the MySQL configuration file to adjust the bind handle of the MySQL server.

Pre-requisites

Ahead of we get begun, ensure you have:

  • MySQL or MariaDB server installed.
  • A root user or an account with sudo privileges.

Once you have the above necessities satisfied, we can carry on.

Step 1 – Edit the MySQL Configuration

The very first step to modifying the bind deal with of the MySQL server is editing the configuration file.

By default, the MySQL configuration file is situated in /and so forth/mysql/mysql.conf.d/mysqld.conf for Ubuntu 20.10

The location of the configuration file could change relying on the MySQL server installed and the Linux distribution.

sudo vim /and so forth/mysql/mysql.conf.d/mysqld.cnf

Although the file is open up, lookup for the entry with the content as (bind-tackle) and modify the benefit to the IP deal with on which the server really should listen.

By default, the value is established to localhost:

In my case in point, I will change the bind-tackle to all, which enables the MySQL server to hear on all IPv4 addresses.

bind-address        = …

Take note: If you use MySQL server variation 8. and larger, the bind-deal with entry may possibly not be accessible. In that case, you can add it beneath the [mysqld] part.

When you are happy with the adjustments to the config file, help you save the changes and near the editor.

Move 2 – Restart MySQL

To implement the adjustments to the config files calls for you to restart the MySQL server provider. You can do this utilizing systemd as:

sudo systemctl restart mysql.services

Stage 3 – Make it possible for Firewall

By default, MySQL listens on 3306, which your firewall can block occasionally. To enable the MySQL server port, use the IP tables command as:

sudo iptables -A Enter -p tcp –vacation spot-port 3306 -j Acknowledge

Stage 4 – Test relationship

After all the configurations are comprehensive, you can check out the connection to the MySQL server.

mysql -u root -h [mysql_remote/-ip] -p

If you have the server configured effectively, you must get the password prompt for the distinct user.

Conclusion

For this brief tutorial, we appeared at how to improve the MySQL bind-deal with to enable the MySQL server to pay attention for connections outside the house the neighborhood machine. This can be incredibly practical when operating with distributed devices.

Thank you, and share if the tutorial served you.

Leave a Reply

Your email address will not be published. Required fields are marked *