user4095898
user4095898

Reputation:

Raspberry PI as databaseserver

I have a question regarding my database and being able to use my db everywhere.

So currently me and some friends are developing an application for android, this application reads alot from his data from a MySQL Database.

Currently we are working on the database design and tought by ourself, how to keep this DB open(24/7) to the app(for the users) and still keep it safe.

My tought is as follow, lets try to run the MySQL database on a Raspberry PI 2.

In our opinion this was do able, but we don't know how to start this.

We can't let the APP give access to the DB because anyone who decompiles our application will get access to our DB. It has to be safe!

So there has te be some portal (php?) In front of the DB who handles the incoming query's

Any suggestions?

Upvotes: 1

Views: 1596

Answers (3)

matrixanomaly
matrixanomaly

Reputation: 6947

There are many guides that show you how to set up mysql on a raspberry pi, in fact they are all fairly step by step. As it is a Debian distribution, sudo apt-get install mysql-server works. Some guides also show you how to set up php for it. So a little google search will go a long way. There migth be performance issues to resolve though.

Just to let you know this is not a correct place to ask for suggestions on software recommendations. That being said your question is probably more suitable for the beta Raspberry Pi StackExchange site, so you should head there for future questions that are not directly programming related.

Upvotes: 0

VaaChar
VaaChar

Reputation: 688

You can build a REST API on your Raspberry PI with PHP and let your app access the database through this API. To make sure that the API can only be accessed from allowed sources you can add a middleware to the REST API to use something like an API-key to control the access.

The data that you pull from the API could be formated as XML or JSON.

Here is a micro framework for a PHP REST API: SlimFramework

Upvotes: 1

rogi1609
rogi1609

Reputation: 438

Yes, you are right. There should not be a direct access. It is a good idea to run a backend which processes requests and only this backend server has database access. A good approach would be to use REST (or SOAP) in order to provide a public API. And depending on the request-URL (REST) you can execute certain methods on the backend, which then performs SQL statements on the database. You can return and send data using JSON.

Upvotes: 0

Related Questions