tarun_tenniso
tarun_tenniso

Reputation: 214

Whats better: direct connection or through php for mysql database

I want to connect to MySql database through windows forms application. I will be inserting bulk data into my MySql database once in a day and thereafter will be inserting only what the user selects.

What is better:

1) direct connection to MySql database through c#

2) php files which takes json data and inserts the data

What now follows is only my strong love for a better approach. The geeks out there I want answer for this:

Which is a better practice, considering a) Security reasons b) Maintenance reasons c) Architecture reasons

Thanks in Advance!! Cheers!!!

Upvotes: 2

Views: 1596

Answers (1)

OlivierH
OlivierH

Reputation: 3890

I think you should choose the second solution :

You will have to access remotely to your database. This is never a good idea to allow remote access to databases, for security reasons :

  • Databases can be subject to DDOS attacks
  • Password can be cracked by brute-force for example
  • Some vulnerabilities of the database software would be usable for hackers ...

Moreover, you would have to ensure that your C# app can communicate with database, means for MySQL that the port 3306 is opened on the machine that executes the app.

The best solution in your case will be to create some PHP webservices just beside your database. Your C# app will call these and send his data, PHP will handle inserts into database.

Advantages :

  • no security issues with your database, since it's only accessible locally.
  • only port 80 (or 443 if you work with SSL) has to be opened on the machine that executes your C#app

Disadvantage :

  • You will have a little delay between the user input and the database insert.

Upvotes: 3

Related Questions