[OT] Access MariaDB from outside

Hi all,

Here an offtopic, because I tried all and I’m going crazy.

I have a server with a MariaDB instance. I have 3306 opened on my router.
I want to connect with DBeaver (or any other Database manager) from my home to my server (located on my office).

  • I have redirected one port to local 3306
  • It’s suppose I have applied the iptables rules
  • I have commented bind-address and skip-network (or something like this) in my.cnf

What the hell more I need to do?

have you tried using a telnet to check the connection can be made?
Regards

Try to set up putty. Then you have a direct channel and that has always worked well for me. (At least for MySQL).

If the server is Linux you can use an ssh tunnel with port forwarding.

E.g.:

  • configure your router to forward [ip-outside]:3306 to [ip-maria-db-server]:22

  • on your pc run and leave it run:
    plink [ssh-user]@[ip-outside] -P 3306 -v -t -C -N -L 127.0.0.1:3306:127.0.0.1:3306 -pw [ssh-user-password]

  • use any mysql\mmariadb client you want and connect it to localhost:3306. as db user\pw you can use whatever you use locally on your db server as mariadb will see the db client connection coming from localhost

plink is a tool included with putty

if the connection is not stable, plink could disconnect and your db client will stop working.
In that case you can create a simple batch with a loop
e.g.
:restart
echo.
plink …
goto restart

For some routers just redirecting the port is not enough. You also have to explicitily enable access on the port.

I forgot this :confused:

Finnally I did an ssh tunnel as explained, and works like a charm.