Koozali.org: home of the SME Server

Remote Access to MariaDB

Offline isotropic

  • *
  • 8
  • +0/-0
Remote Access to MariaDB
« on: July 19, 2025, 04:41:42 AM »

Good evening, gentlemen.
I can access MariaDB. I created a user with a password. But I need to access it remotely. Can you teach me how to open port 3306?
And, if it's not too much to ask, can you show an example of a connection via JDBC?
I use SME 10.1.
Thank you in advance.
Best regards.

Offline ReetP

  • *
  • 3,957
  • +6/-0
Re: Remote Access to MariaDB
« Reply #1 on: July 19, 2025, 08:33:54 AM »
I can access MariaDB. I created a user with a password. But I need to access it remotely. Can you teach me how to open port 3306?

So always check the docs - you'll learn more that way.

https://wiki.koozali.org/Mariadb105

Quote
And, if it's not too much to ask, can you show an example of a connection via JDBC?

I have no experience of that. See the notes in the wiki on urls.

Also, bearing in mind your questions (Tomcat too) be VERY careful with what you are doing.

Exposing services remotely when you're not really sure of what you are doing is a rapid route to getting yourself hacked.

Always ask yourself "do I absolutely have to do this or is there a better way?"

As you haven't described what you are actually trying to achieve in either of your posts, I can see you becoming a XY Problem if you aren't careful...... I'm not trying to be unkind, just saving you from yourself!!

https://xyproblem.info/

You may want to read this too.

https://forums.koozali.org/index.php/topic,54724.0.html

Take a deep breath and start from the beginning!!
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline isotropic

  • *
  • 8
  • +0/-0
Re: Remote Access to MariaDB
« Reply #2 on: July 19, 2025, 01:45:27 PM »
Hello, gentlemen, good morning!
I'm Isotropic, from Brazil.
I'm a JAVA programmer and I study at a Philosophy School.
This school needs support in the IT area.
That's why I decided to learn the basics of Linux so I could set up a network where teachers could share their work. The most basic thing possible. I tried TruNAS. Rokstar. Several options available. Until I discovered SME Server. Love at first sight! I'm studying to learn a lot and be able to participate in the version 11 testing.

Offline isotropic

  • *
  • 8
  • +0/-0
Re: Remote Access to MariaDB
« Reply #3 on: July 19, 2025, 01:49:10 PM »
To answer your question:
I only want an internal network. 192.168.160.0. That's it. No external access.
On this network, with Tomcat and MySQL, I can install small applications to help with its operation. Things like student registration. Books in the library. Things like that. No external access. A completely internal network.

I'm very happy and gratified to have discovered SME Server. And I intend to participate more actively. Since I don't have enough knowledge to help with development, I intend to participate in testing. Or even through donations.
I want to thank you for the help I'm receiving. And I want to say that I would never try to jeopardize the work I'm trying to develop.
Thank you.

Offline isotropic

  • *
  • 8
  • +0/-0
Re: Remote Access to MariaDB
« Reply #4 on: July 19, 2025, 02:00:19 PM »
When I say I want 'external access on port 3306,' I mean I intend to access MariaDB on a Windows computer, where I work best. With this access, I can create application tables using a front-end like MySQL-Front. But always on the internal network. Within the limits of 192.168.160.0.

Offline Jean-Philippe Pialasse

  • *
  • 2,913
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Remote Access to MariaDB
« Reply #5 on: July 20, 2025, 05:05:52 PM »
be aware that even if you enable access only on lan, access mariadb this way is by default in clear.

meaning anyone on the network can recover your username and password and see your data.

if you open access to the network you need also to manually configure encryption for mariadb and your user and force your user to only connect with encryption. 
this is a lot of work to manually configure and you need to consult mariadb documentation to do that as this is not implemented in SME. 

also do use a dedicated user with only access to one db. 

Offline ReetP

  • *
  • 3,957
  • +6/-0
Re: Remote Access to MariaDB
« Reply #6 on: July 20, 2025, 05:28:45 PM »
^^^^^^^^^^^^^^^^

What he said. As el Presidente, Head Honcho y el Jefe, he knows a bit :lol:

Better to describe exactly what you are building and maybe we can help.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline isotropic

  • *
  • 8
  • +0/-0
Re: Remote Access to MariaDB
« Reply #7 on: Yesterday at 12:52:36 AM »
Good evening, gentlemen.
 Jean-Philippe Pialasse, ReetP...
I've read and reread your messages and realized my mistake: I shouldn't allow remote access to MySQL. It's really very dangerous.
Thank you for the advice.
Safety always comes first!
Best regards.

Offline isotropic

  • *
  • 8
  • +0/-0
Re: Remote Access to MariaDB
« Reply #8 on: Yesterday at 01:02:55 AM »
Hello, ReetP, good evening.
I just want to set up a basic IT department at the school where I study.
An internal network. 192.168.160.0. That's it. No external access.
To allow file sharing among teachers.
On this network, with Tomcat and MySQL, I can develop small applications to help it run smoothly. Things like student registration. Library book registration.
Things like that. Very basic. No external access.
Cheers.

Offline mmccarn

  • *
  • 2,657
  • +10/-0
Re: Remote Access to MariaDB
« Reply #9 on: Yesterday at 01:57:52 PM »
Can you teach me how to open port 3306?

CAVEAT: I HAVE NOT DONE THIS FOR YEARS, BUT THE PROCEDURE BELOW *MAY* DO WHAT YOU WANT...

mariadb connections use sockets by default, which do not allow remote connectivity.

* Allow mariadb to communicate using networking (but only from the server for now, to maintain security)
Code: [Select]
config setprop mariadb AllowHosts 127.0.0.1 LocalNetworkingOnly no port 3306
signal-event post-upgrade; signal-event reboot

* Use an ssh tunnel from your workstation to the sme server:
(I do this using cygwin on windows, but windows11 may already include OpenSSH)
Code: [Select]
ssh -L3306:127.0.0.1:3306 <user>@<sme-server>(-L <local port to listen on>:<ip or systemname as it appears to the remote system>:<remote port>)

* Then configure the tools on your workstation to talk to "localhost:3306" instead of directly to the SME server.

Performance is likely to take a hit, but if it works you can research how to configure mariadb for secure connections.  Mariadb "secure connections overview"

Offline ReetP

  • *
  • 3,957
  • +6/-0
Re: Remote Access to MariaDB
« Reply #10 on: Yesterday at 02:12:29 PM »
Or write/use apps direct on the server itself.

I'm sure there are plenty of applications out there that you could use.

If you mention specifics eg I think you said some sort of library system? other users may have some suggestions.

...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation