使用 MSSQL 数据库和 MySQL 数据库 [英] Working with a MSSQL DB and a MySQL DB
问题描述
我正在服务器中处理 PHP 脚本
.我有两个数据库:
I am working on a PHP script
in a server. I have two databases:
- 第一个是
MySQL DB
,它已经导入我的服务器,所以连接成功. - 第二个是
MSSQL DB
,我想将它从另一台服务器导入到我的.
- 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.
问题是我不知道是否可以以某种方式将 MSSQL 安装到服务器上,并且在搜索时没有找到任何解决方案,或者我是否应该同时连接到两台服务器.你能帮我解决这个问题吗?最好的解决方案是什么?
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.
推荐答案
您似乎没有在 php.ini
文件中启用 MSSQL 扩展.
It seems you didn't enable the MSSQL extension in php.ini
file.
在 Linux 中
您会在 php.ini 文件中找到它:
;extension=mssql.so
并替换为:extension=mssql.so
(只需删除分号启用.)
You will find this in php.ini file :
;extension=mssql.so
and replace with this :extension=mssql.so
( just remove the semicolon to enable.)
您会在(如果您使用的是 xampp linux)中找到一个文件lampp/etc/freetds.conf 文件.在这个文件中你需要添加如下配置.
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.
添加:
[DevSqlServer]
[DevSqlServer]
主机 = 172.16.1.123
host = 172.16.1.123
实例 = DEVAPSERVER
instance = DEVAPSERVER
端口 = 1433
tds 版本 = 7.0
tds version = 7.0
重启你的服务器.而你的php代码应该是这样的.
Restart your server. and your php code should be like this.
在这里你可以看到我做了什么.DevSqlSerrver 我已经给了freetds.cof.所以我需要给出我所拥有的服务器名称在 freetds.conf 中给出.
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);
并且您可以访问 MSSQL Server 数据库.
And you can access MSSQL Server database.
更多信息:
这篇关于使用 MSSQL 数据库和 MySQL 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!