Can I connect to MySQL db from my app?

I am making an ElectronJS app that needs to connect to an external database because the app runs locally in each client’s PC.

So, I have read that I can’t connect to any db in the free plan from external software such as MySQL Workbench, but I will be allowed to connect the database to make petitions through my app?

You can create a file on your website that will connect your app with your website by receiving and returning data …

For example: you can make it that it receives the user name and password form an input in your app, then the website searches for the user in your database using PHP. If the user has been found within your database, then the website will return a JSON string with the data that you want to get from the database.


The short answer is no, you cannot do this. And frankly, for almost all applications, you shouldn’t even want this.

First of all, having every client application connect directly to your database is a really bad idea. Not only are MySQL connections generally unencrypted, but it’s very hard to control what each user can do within the database. It’s very hard to make sure that each user can only see their own data and make changes which your application allows. Once you give them permissions to access your database, they can do almost anything.

This will also straight up not work on free hosting. Our databases can only be reached through the internal network of our hosting cluster, and are unreachable to internet at large.

The right way to do it is like @EnderAdels_Account said: write a PHP application with authentication where you can control what each user can do within the server side application. That way, you can select only the data which the user is allowed to access, and validate the changes made against your own rules.

However, this also will not work on free hosting, because it is website hosting, not database or API hosting. There are security systems preventing you from hosting applications like that.


This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.