0

New setup of Ubuntu 20.04 and MariaDB. MariaDB works fine locally, but I cannot access it remotely. I've searched online and think I've done what's suggested so there may be a step I've missed.

Here's what I've done thus far:

GRANT ALL ON 'admin'@'%' IDENTIFIED BY 'THEPASSWORD';
FLUSH PRIVILEGES;

I then changed the bind address to:

bind-address            = 0.0.0.0

in file /etc/mysql/mariadb.conf.d/50-server.cnf

(Note that the file /etc/mysql/my.cnf doesn't have any bind-address information in it.)

In AWS firewall, I added port 3306 to the incoming ports for all locations.

The error I get trying to connect remotely is is:

2002 - Can't connect to server on '(Ip address here)' (36)

I've tried using both the IP of the server and the DNS name. Both approaches give same error.

What could I be missing?

Thanks!

1 Answer 1

0

As of security reasons I prefer to set up port-forwarding (tunnelling) through SSH between two linux hosts. I suppose you have a SSH access to the host with MySQL/MariaDB on it:

ssh user@dbhost -N -f -L localhost:3306:localhost:3306  

This is a bit weird syntax meaning literally:

port 3306 on 127.0.0.1 of the working machine should be tunneled to the port 3306 on 127.0.0.1 on the remote machine DBHost having DB service running. Then on the localhost you'll see a listened port 3306 by

ss -l | egrep "3306|mysql"

Now you need a MySQL/MariaDB client installed on the working machine and you can connect to the remote host in a plain straightforward way:

sudo mysql

Local client will connect to the local port 3306 that will be forwarded to the dbhost:localhost:3306. Service's answers will be routed back through the SSH tunnel.

If you already have another MySQL/MariaDB running on working machine and you do not want to mix it up with a remote one just change port nmber to any other:

ssh user@dbhost -N -f -L localhost:3308:localhost:3306
sudo mysql -P 3308
3
  • The steps I did above (minus the 0.0.0.0 step) were all I've ever had to do to get MySQL remotely accessible. I'm now wondering if MariaDB is going to be too painful to get working and maybe I should punt and install MySQL instead. Thanks.
    – Morkus
    Commented Jan 17, 2023 at 20:59
  • The MariaDB networking and compatibility with this is identical to MySQL. You won't save any hassle by moving to MySQL.
    – danblack
    Commented Jan 18, 2023 at 3:09
  • 2
    Looks like the problem was another piece of software installed on the server. That software basically takes over the machine and installs its own firewall. Very non-standard. My solution was to just spin up another AWS Linux instance and everything worked fine there. Thanks to all!
    – Morkus
    Commented Jan 18, 2023 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.