bind-address = 0.0.0.0 in the server config (/etc/mysql/mariadb.conf.d/50-server.cnf for MariaDB or /etc/mysql/mysql.conf.d/mysqld.cnf for MySQL on Ubuntu), restart the service, create a user for the client’s IP such as 'app'@'198.51.100.25', and allow port 3306 in your firewall from that IP only.
Before you start
- Know the public IP address of the machine that will connect (your app server or your home connection). In these examples the client is
198.51.100.25and the database server is203.0.113.10. - Have a firewall running. See UFW or firewalld.
- Back up your databases before changing the server.
Why can’t I connect to MySQL remotely?
On Ubuntu and Debian, MySQL and MariaDB only listen on127.0.0.1 after installation, so only programs on the server itself can connect. Remote access needs three things to line up:
- The server listens on a public address (
bind-address). - A database account exists for the client’s IP address.
- The firewall lets that IP reach port
3306.
How to allow remote MySQL connections
1
Change bind-address
Open the config file for your server:Under
[mysqld], change the line to:0.0.0.0 listens on every IPv4 address. To listen on one address only, use the server’s IP, for example bind-address = 203.0.113.10. If the file contains skip-networking, remove that line or comment it out with #.2
Restart the database server
- Ubuntu / Debian
- AlmaLinux / Rocky
3
Create a user for the client's IP
Open the shell with This account only works from
sudo mariadb (or sudo mysql) and run:198.51.100.25. A user that already exists for localhost is a separate account and keeps working.4
Open port 3306 to that IP only
- Ubuntu / Debian (UFW)
- AlmaLinux / Rocky (firewalld)
How to check it worked
On the server, check what MySQL listens on:127.0.0.1:3306, the bind-address change is in the wrong file or the service was not restarted. MariaDB can print the setting it actually uses:
mysql> or MariaDB [shop]> prompt means it works. To test only the port, see check if a port is open from outside.
Troubleshooting remote MySQL connections
Frequently asked questions
Is it safe to set bind-address to 0.0.0.0?
Only together with a firewall rule that allows specific IPs.bind-address decides which addresses MySQL listens on; the firewall decides who can reach them.
My home IP changes. What should I do?
Use an SSH tunnel instead of opening the port. A tool such as HeidiSQL connects over SSH and reaches MySQL on127.0.0.1, so nothing extra is exposed.
Does remote MySQL traffic use encryption?
Not unless you set up TLS. Without it, queries and data cross the internet in plain text. An SSH tunnel or a private VPN such as WireGuard encrypts the connection.How do I undo remote access?
Setbind-address = 127.0.0.1 again, restart the service, delete the firewall rule and run DROP USER 'shopuser'@'198.51.100.25';.
Related guides
VPS and dedicated server guides
Every guide in this section.
Create a database and user
How the user and host part work.
Connect with HeidiSQL
Use an SSH tunnel instead.
Set up UFW
Allow ports from chosen IPs.
Check open ports
See what your server listens on.
Checked against the official MariaDB remote connection guide, Ubuntu Server documentation and Red Hat database server guide on 4 November 2026; config files, SQL and the UFW rule (dry run) tested on Ubuntu 24.04 LTS with MariaDB 10.11. Commands can differ on other distributions or releases.
Need Extra Help?
If you encounter any issues, our support team is ready to assist:- Live Chat: Quick assistance via our website.
- Support Ticket: Open a Ticket
- Discord: Join our Community
- Email: support@freakhosting.com
Last Updated: November 2026