Connecting to an external MySQL database from a web server not running MySQL

While I have been working with MySQL for many years, this is the first time I have encountered this newbie-esq problem. Due to client requirement, I have to host my site files (PHP) on an IIS server that doesn't run MySQL (they run MSSQL instead). However, I developed the site using a MySQL database that is on an external host (Rackspace Cloud). Obviously my mysql_connect function is bombing now because MySQL is not running on localhost.

Question: Is it even possible to get into an external MySQL database if localhost doesn't start MySQL?

Apologies for the rookie and thanks a lot in advance.

* To clarify, I know how to connect to a remote MySQL server, but it is a fact that ANY MySQL form (neither server nor client) is running on my IIS web server which is causing me problems. In other words, phpinfo () returns nothing about MySQL. *

+2


a source to share


4 answers


Yes, you can use a MySQL database that is not on the same machine as Apache + PHP.

Basically, you will be connecting from PHP to MySQL over a network connection - based on TCP, I suppose; which means:



  • MySQL must be configured to listen for and accept network interface connections
    • What does setting up MySQL mean for this
    • And given the required privileges for your MySQL user, so it can connect from a remote server
  • And PHP must be able to connect to the server that hosts MySQL.

Please note, however, that using MySQL on a remote server can be awkward to execute: every SQL query must go over the network, and this can take some time ...

+3


a source


If phpinfo returns nothing about MySQL, you need to install the MySQL plugin for PHP, the easiest way to do this is to simply update PHP to the latest version. If there is no .DLL file you need.



http://www.php.net/manual/en/mysql.installation.php

0


a source


you will need to install the mysql extensions. this link should help: http://php.net/manual/en/install.windows.extensions.php

0


a source


The MySQL server has nothing to do with PHP itself. "Mysql support" in PHP means that it has been compiled (or loaded by a module) that implements the MySQL client interface. For windows this will be "mysql.dll" and on Unix-ish systems it will be "mysql.so". Once loaded, the various MySQL queries (mysql_xxx (), mysqli_xxx (), PDO, MDB2, etc.) will be able to access any MySQL server anywhere as long as you have the correct connection string.

0


a source







All Articles