How do I connect a desktop app to an hosted database - mysql

I am developing a desktop app and I want to store data in hosted database like MySQL/MongoDB. I know one solution is using webservice to manipulate db. I am wondering is there a way to connect desktop app with hosted db directly.
I am using OpenShift I know I can use port-forward to do this. But it's unpractical to open port forward every time for every PC. So is a way simply like this:
mongoose.connect('mongodb://user:pass#host:port/db');
I tried this but I got 'connect refused' or 'connect not found' errors. OpenShift doesn't allow external access to database directly because security issues, right? Then how could I do it without port-forward?
Also I read some articles about SSH, is it possible to use SSH to access db directly when desktop app is launched?
Thanks for any suggestion.

I don't think OpenShift is going to be a good fit for what you are trying to do, unless you decide to build a service layer between your desktop app and the database. It sounds like you are looking for a Database As A Service. You mentioned both MongoDB and MySQL. MongoLab is a good MongoDB DBaaS option. For other databases like MySQL, PostgreSQL and several others you could look at Amazon RDS.

Related

How to connect to my mysql database installed in my host (domain)

I want to develop a desktop application (with VB) and connect it to an online database (MySQL), I already had my hosting site and I thought why not create a MySQL database in my domain (which by the way is offered in the pack) and connect my desktop application to this database.
Why an online database? Because I want to develop a mobile application to keep me informed of any changes in my business without moving to my office.
The problem is that my VB6 application cannot connect to my MySQL due to domain restrictions. I wondered how these thousands of apps work with online data? What are their magic solutions? Or did I miss something?
Please any idea? I worked with VB6 and a local database which is no longer productive.
You can create a simple PHP file on your server that will take the data from your VB6 apps and store it in your database. You can also create a simple PHP file that will query your database and return the results in a format that your app can read. This is the typical way that a VB6 app will interact with a server-side database.

Accessing Mysql Database from a Machine to another machine using an application

So, I basically made a Windows Application using Visual Studio 2019, and used MySQL as my database to store records.
Now I want to publish that application and send it to a client or try to run it on a different machine, but i think since i have used the localhost as my database connection it wont be able to read or write data on my database from another machine.
So basically I want to know how can i host my mysql database on a machine and access that database from another machine using an application.
I am unable to find any sort of guide to do it online, if someone can guide me or give me a referrence from where I can get information and solve my issue.
You can expose your localhost to be accessed remotely, However, this is not ideal or advised. I will suggest you host your database on one of the virtual or cloud services and access it in your application.
Examples of services like https://remotemysql.com/ https://www.db4free.net/ which I advice you use for testing purpose only. You can create your database and they will give you the connection parameters to fill your connection string.
Let me know if is helpful.

How to use relational DB with online/offline replica with Electron-Node?

I am just starting to use Electron and I have a question about databases. Due to the kind of App I am developing I need a relational DB.
The idea is the user will open the App, if there is connection it would store the data both locally and remotely. If the App is offline it will store the data locally and whenever is online again it will send that data to the remote server. Basically it will be thee same database (local and remote) but it can work offline if necessary.
I am lost on which database will be better for this. As I said I am using MySQL right now and I know you can use MySQL with nodejs so I might give it a try. Also, I am used to use MySQL within a backend language such as PHP, how would you do it in Electron?
Thanks for your time guys!

Connect to MySql database through xamarin

I'm currently doing a iOS application for school to connect to school mysql database.
It should be able to connect to it through the tools on xamarin studio.
I tried a lot of different coding to connect the database, but was unable to do so.
Is there any tutorial or example code to let me learn on how to do it ?
Thanks for any help!
Do not connect directly to a database from a mobile app. Doing this requires exposing your database server directly to the web, which is a horrible security risk. The better approach is to use a web services layer to broker the interaction between your client and your server.
http://docs.xamarin.com/guides/cross-platform/application_fundamentals/web_services/
While people are right and the best way to connect to a database is to use a web service there are some times you want to connect directly and ways to make the connection more secure (ip restrictions on the mysql server).
Here is a plugin with code examples on how to do it:
https://components.xamarin.com/view/mysql-plugin
Be sure to pay attention to the first forum question on errors and how to resolve. You need to include a reference to system.data, I18N, I18N.West in your project and also make a call to the constructor for I18N somewhere in your code.
new I18N.West.CP1250();

How to write to a remote DB from an android app

We have an android app that currently sends data to a php script which writes to a mysql DB on the same server. We are thinking of using a scalable DB server e.g. FathomDB (which is just based on amazon RDS & rackspace) so that we can handle load increases easily.
The question is how does our android app write to these remote DBs? Do they have some kind of rest API, or allow you to have a php script similar to the one we have in place at the moment?
I'd say most of services like these have a connector running on the web, like the one you are using. But some of the services you mention (for example amazon rds) have a native mysql connection. So you can connect using mysql to the server and run queries like you currently do in php. You can use ACL to ensure security in your application :)