Last updated on October 9th, 2024 at 09:16 am.
In this post, you’ll see how to access MariaDB remotely. By default, Mariadb server is only accessible on the localhost where it is installed.
First step, create a DB user for accessing the database remotely and then grant that user permissions to access that specific DB:
#Log into mysql. Create user. Grant permissions to the user.
CREATE USER 'rdbuser'@'192.168.125.113' IDENTIFIED BY 'passworddiuser';
GRANT ALL PRIVILEGES ON databasename.* TO 'rdbuser'@'192.168.125.113';
# View all users
select user, host from mysql.user;
Next, add a bind address to your mariadb server.
# Remember to get the right file to configure. Add your server IP next to the bind address separated by a comma
sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
Finally, allow your IP to access the mariadb port via the firewall. Save the rule and reload the firewall if needed.
#For UFW
sudo ufw allow from 192.168.125.113 to any proto tcp port 3306
#For IPtables
sudo iptables -A INPUT -p tcp -s 192.168.125.113 --dport 3306 -j ACCEPT
#For nftables
sudo nft add rule inet filter input ip saddr 192.168.125.113 tcp dport 3306 accept
Discover more from Bizanosa
Subscribe to get the latest posts sent to your email.