I’ve got a webserver running quite standard Apache/php/MySQL and want to connect to this MySQL database from a desktop application written in c#/wpf.
First, how can I connect? Do I need some special SQLConnection library?
Second, how safe is this? Anything special I need think about for security since the database is in the web and not local?
You could connect to MySQL if you allow connections (to MySQL) from the IP addresses the desktop (WPF) clients are running from. Just create users and allow them to connect directly to the database. It’s not unsafe. But your MySQL repository could become harder to maintain (you will have lots of users, logging from different subnets, etc.).
I would recommend to create a WEBSERVICE or RESTFUL API in your Apache/PHP/MySQL Server, and connect to that service with C#.