问题
I am working on a PHP script
in a server. I have two databases:
- The first one is a
MySQL DB
and it is already imported to my server, so it is connected successfully. - The second one is a
MSSQL DB
and I would like to import it from another server to mine.
The problem is that I don't if I can install MSSQL somehow to the server and I haven't found any solution while searching for it or if I should connect to the two servers simultaneously. Could you maybe help me with that? What is the best solution?
I hope it is not that simple question, but I am a bit new in server administration.
回答1:
Your PHP installation doesn't have MsSQl Extension available. Install MSSQL extension for PHP and it will work. Usually you just have to open a line in php.ini and make sure that mssql module is there in extension folder. restart web server and it will work
回答2:
It seems you didn't enable the MSSQL extension in php.ini
file.
In Linux
You will find this in php.ini file :
;extension=mssql.so
and replace with this :extension=mssql.so
( just remove the semicolon to enable.)You will find a file in (if you are using xampp linux) lampp/etc/freetds.conf file. In this file you need to add the following configuration.
add this:
[DevSqlServer]
host = 172.16.1.123
instance = DEVAPSERVER
port = 1433
tds version = 7.0
Restart your server. and your php code should be like this.
Here you can see what i have done. DevSqlSerrver i have given in the freetds.cof. So i need to give the server name that what i have given in freetds.conf.
// Connect to MSSQL $connection = mssql_connect("DevSqlServer", 'sa', '****'); $db_connect=mssql_select_db("DBname",$connection);
And you can access MSSQL Server database.
For more info:
Link1
Link2
来源:https://stackoverflow.com/questions/16963282/working-with-a-mssql-db-and-a-mysql-db