With this is mind, we at least have to add a warning on the dangers of enabling remote MySQL access on your site:Įnabling remote access to your database means that you are accepting the fact that you would be jumping several layers of security that make your site safer in many ways and offer you peace of mind as a partner. That’s all! In this article, you have learned helpful insight into the common ideas of remote MySQL access in Linux.Advanced members with knowledge on database, programming and security might want to enable remote MySQL access to their site because of faster development, quicker access or any other reason that would be related to the need of having remote access to the database. $ sudo iptables -A INPUT -p tcp -s remote_ip_address -dport 3306 -j ACCEPT Iptables $ sudo iptables -A INPUT -p tcp -dport 3306 -j ACCEPT $ sudo firewall-cmd -permanent -zone=mysqlrule -add-port=3306/tcp ![]() $ sudo firewall-cmd -permanent -zone=mysqlrule -add-source=remote_ip_address UFW Firewall $ sudo ufw allow from remote_ip_address to any port 3306įirewallD $ sudo firewall-cmd -new-zone=mysqlrule -permanent If you have a firewall enabled on your remote server, you might need to grant access to MySQL’s default port 3306 and grant access to remote_ip_address as shown. $ mysql -u remote_user -h 192.168.50.130 -pĪnd just like that, you can directly and remotely gain access to a MySQL database server from a remote client computer configured to an IP address of your choice. Re-attempt remote access to your MySQL server. Sign-in back to your MySQL server via SSH and implement the command: mysql> ALTER USER IDENTIFIED WITH mysql_native_password BY 'password1122' Īfterward, exit the MySQL database shell and restart the MySQL daemon. If you run into the above error as depicted by the screen capture, you will need to configure your MySQL user to use a native password. In our case, the command will look like the following: $ mysql -u remote_user -h 192.168.50.130 -p To directly connect to the MySQL database server remotely, adhere to the following MySQL syntax: $ mysql -u username -h mysql_server_ip_adress -p $ sudo systemctl restart mysqlįind Linux Server IP Address Attempting Remote MySQL Database Access ![]() Restart Your MySQL server and then identify the IP address of the MySQL server. Afterward, any IP address will be allowed to access it. These configuration changes will prevent the server hosting MySQL database software from only relying on localhost (127.0.0.1) connections. To allow remote access to your MySQL database server, the fields bind-address and mysqlx-bind-address need to be commented out. To give access to other users’ IP addresses to your database server, navigate and open the file MySQL configuration file. By default, the MySQL bind-address is 127.0.0.1 which implies that only localhost users can interact with the MySQL database. Now that we have the remote user created, it’s time to perform some additional configuration changes. mysql> GRANT ALL PRIVILEGES ON *.* TO FLUSH PRIVILEGES For instance, this user can have the same database privileges as the root user only that the root user is bound to the host machine. Let us grant this user some database privileges. mysql> CREATE USER IDENTIFIED BY 'password1122' To create a new MySQL user, we will adhere to the command syntax: CREATE USER IDENTIFIED BY 'your_user_password' Īs you have noted, we are using the notation and not since we want this user to be dynamic enough to access the MySQL server from any other host machine with a different IP address. It is advisable to work with a remote user who is neither a root MySQL user nor tied to the remote server hosting the MySQL database software.Īccess your remote MySQL server and database via SSH. On the remote server/machine hosting your MySQL database software, we need to perform a few configuration steps for it to allow authenticated remote users access. This article guide will walk us through setting up and enabling remote access to a MySQL server in Linux. You can now have the MySQL running on a remote dedicated server and still be guaranteed the same database security and performance as the case with a MySQL running on a local/desktop machine. Therefore your MySQL does not need to reside on a local machine for you to fully benefit from its functional features. ![]() ![]() You do not need to be physically present in order to interact with your remotely hosted software. The software ecosystem is not new to the notion of distributed systems.
0 Comments
Leave a Reply. |