I have some mini apps hosted on website and the main app and database on another. I need to connect from the mini apps server to the main mysql database and do some queries. My question is how safe is this kind of connection ? I could copy the tables I need from the main server to my mini apps server but this would mean weekly or more often exports and imports and I don’t like this solution.
I work as website admin for several of the websites I’ve built from scratch, so I’m very conscious of maintenance concerns. Like you I shudder at the added maintenance load of imports and exports between your two servers.
The real crux of the issue here, is that a call to a MySQL db on any server is a call to external resources. You should have some validation / sanitization security in place either way, but I don’t believe one is really less secure than the other. The call to the other server’s database is no “less trustworthy” than the call to the DB on your own server. While someone might take advantage of a DB connection, most DB security issues comes from people using your own application machinery (form input elements, GET and POST data) to put bad things into your database. As long as you check your DB through a sanitization whitelist and validate the data to be sure that it won’t cause any problems you’re fine; and since you need that level of security in either case, I don’t think you need “extra” measures for the off server DB connection.