How to enable remote access to Mariadb database ?
Hi, I'm back. Today, let's see how we can enable remote access to your database. Most of them thought it will be just enabling port but there are some additional changes needed to enable remote access to your MariaDB database.
Step 1
First, we need to access the server via SSH so we can edit the Mariadb configuration. However, there are 2 possible cases here but first, we need to know your MariaDB version. You can easily get the same from your server's service page.
If your MariaDB version is below or equal to 10.4 then the configuration you need to edit is /etc/mysql/my.cnf
If the version is above 10.4 then you can find your configuration in
/etc/mysql/mariadb.conf.d/50-server.cnf
Now, we can edit this file by using either nano or vi. For freshers, I will suggest nano.
nano /etc/mysql/mariadb.conf.d/50-server.cnf
We have two options to enable. The easiest option is to comment "bind-address" like below(Add a # to that line, which will comment that line)
#bind-address = 127.0.0.1
Another option is adding these 2 lines.
skip-networking=0
skip-bind-address
Step 2
Once done that, you can just add restart your MariaDB service using below
command.
service mysql stop
service mysql start
Now that we added configuration and the service is running, we just need to do one final step. Please go to your RunCloud and Server provider firewall and add port 3306. However, it's recommended only to enable this for your public IP/external server IP instead of globally opening port.
Step 3
We can verify it's working using the telnet command.
telnet your_server_IP 3306
This will give you the result look like below
Trying your_IP...Connected to Your_IP.Escape character is '^]'.o5.5.5-10.5.12-MariaDB-1:10.5.12+maria':1$amysql_native_password
I hope this tutorial helped you with the issue :)
GHost '45.32.245.50' is not allowed to connect to this MariaDB serverConnection closed by foreign host.
ReplyDeleteHave you tried with a different database user? Make sure the user has the required privileges.
DeleteI don't know what happend i'm a developer and client purchased a runcloud server Ubuntu i have connected my git repo in runcloud also need to connect db that's why i'm facing problem still stuck in last week can you help me.
ReplyDeletePlease share the details in hangout or email, I will take a look when available. linuxtutorialz@gmail.com
Delete