Wednesday, April 11, 2012

Connect to MySQL via PHP script tunnel

Here's the question, I need to connect to a remote MySQL database from my C# Application, problem is the MySQL instance will block all access to all IP's apart from localhost, this can not be changed as its too much of a security issue.



The question is, is it possible to connect via a tunnel instead to a php script hosted on the server, this would then act as the mysql connection.



Any ideas and suggestions?





2 comments:

  1. SQLYog (a mysql management GUI utility) already has this php tunnel script with its own custom API, so if you consider writing it yourself, would be nice to have cross-support. See Is there any good universal PHP MySQL HTTP tunnel?

    ReplyDelete
  2. yes, just create a simple PHP script that will give you the desired output and use http request from the c# application to that php script to get the data - basically, you'll be building a very simple REST API (with authentication)

    p.s. I don't see how that would be more secure than SSH tunnelling

    ReplyDelete