Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to access a DB that is on a remote server?
In the past was really easy to setup a server using IIS on Windows on a Web based server, where all clients access via browser using a dyndns url, i only needed to forward port 81 to get access to my web site.
Now, with Qt, i have done my client as a desktop application, so as you can see, i guess there is nothing to do with port 80, 81 etc...
The web-based client flow is : internet client via web browser -> server web browser -> database.
In Desktop is direct : internet client desktop -> server database
My Server in this case has MariaDB using port number 3306, root & pass and a no-ip url to get from outside.. No-IP is already setup and working, but i have no idea how i need to configure my server to make it listen my outside client... Do i still need to forward the server lan ip on the router?..
Thanks in advance.
Do you mean you want it make your database facing internet directly ?
Hi, yes, a remote client accessing directly to a database that is hosted on a remote server. Web based applications do not do this instead the server side app is the middleware between client and database, but in my case is direct...
artwaw last edited by artwaw
apart from what I think of exposing any db directly to the internet in order to get access from Qt based application you just need to provide necessary data to the QSqlDatabase instance:
- public ip address (or url) of the database;
- username and password;
- all others optional parameters.
It is all described in the documentation.
artwaw last edited by
@U7Development also, you wrote:
My Server in this case has MariaDB using port number 3306, root & pass and a no-ip url to get from outside.. No-IP is already setup and working, but i have no idea how i need to configure my server to make it listen my outside client... Do i still need to forward the server lan ip on the router?
My understanding is that you have the server on the LAN somewhere and would like to connect remotely over the Internet?
In this case you need to forward the port of the DB from the outside (the internet) to point into your server's ip (inside) on your router. This can be done as a simple port forwarding/triggering in simpler models of the routers.
To connect you'll need to know public IP (or URL should you have one) of the router and use this to connect. That kind of setup might be tricky though if you have dynamic IP address on the router (and setting this up is a bit outside of topics on this forum).
So practically the only thing i need to do is to portforward port 3306 for the server ip on LAN 192.168.1.200 and automagically DB will be available for remote Qt desktop client isn't ?
artwaw last edited by artwaw
@U7Development In theory, yes. In practice there still might be network issues preventing successful connection (that kind of setup is quite complicated to debug as there might be both software compatibility issues and routing issues on the network). Try it, see if it works.
Also, if your router permits any kind of logging it might be worth settings this up to monitor network connectivity - especially with regards to port forwarding.
Side note - please check if your router allows exposing "applications" to the outside interface, some built in router firewalls have that option. From my experience using this option in the router firewall works more often than simple port forwarding.
As I said, there are multiple non-exclusive points of failure in that kind of setup.
@artwaw yes, agreed... i need to contact to my ISP to check if my modem-router is enabled to port forwarding or permit access from outside by firewall as you said..... otherwise i will need to buy a custom router and set ISP modem to Bridge..
@U7Development You should seriously rethink your approach - exposing databases directly to the Internet isn't a good idea...
Bur8rus Banned last edited by Bur8rus
This post is deleted!