我正在尝试连接MSSQL服务器,但遇到了一些困难。首先,我的服务器引发以下错误:
消息:SqLSTATE[HY0000 ]无法连接:自适应服务器不可用或不存在(严重性9)
嗯,我想我成功地安装了freetds,因为我做的每一个检查都显示一切正常。
MSSQL配置:
PDO配置:
我尝试连接:

[local : production]
resources.db.adapter = "pdo_mssql"
resources.db.params.pdoType = "dblib"
resources.db.params.charset = "utf8"
resources.db.isDefaultTableAdapter = true
resources.db.params.driver_options.ReutlocarnDatesAsStrings = true
resources.db.params.dbname = "database"
resources.db.params.host = "server-ip"
resources.db.params.username = "user"
resources.db.params.password = "password"

安装的模块
rodrigo@thx1138 ~   [15:51:16]
$ php -m | grep "mssql"
mssql

rodrigo@thx1138 ~ [15:51:28]
$ php -m | grep "pdo_"
pdo_dblib
pdo_mysql

我的freetds.config:http://pastebin.com/qA0XwFVD
我的nmap输出
Starting Nmap 6.40 ( http://nmap.org ) at 2014-07-02 17:48 BRT
Nmap scan report for host (IP)
Host is up (0.00049s latency).
Not shown: 919 filtered ports, 74 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
25/tcp   open  smtp
80/tcp   open  http
139/tcp  open  netbios-ssn
1433/tcp open  ms-sql-s
3128/tcp open  squid-http
3389/tcp open  ms-wbt-server

这是我的freetds设置
tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds v0.91
             freetds.conf directory: /usr/local/etc
     MS db-lib source compatibility: no
        Sybase binary compatibility: no
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 5.0
                              iODBC: no
                           unixodbc: no
              SSPI "trusted" logins: no
                           Kerberos: no

当我试图通过freetds连接时,出现了一个错误:
rodrigo@thx1138 ~
> $ tsql -S server-ip -U user
Password:
locale is "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=pt_BR.UTF-8;LC_TIME=pt_BR.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=pt_BR.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=pt_BR.UTF-8;LC_NAME=pt_BR.UTF-8;LC_ADDRESS=pt_BR.UTF-8;LC_TELEPHONE=pt_BR.UTF-8;LC_MEASUREMENT=pt_BR.UTF-8;LC_IDENTIFICATION=pt_BR.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20009 (severity 9):
    Unable to connect: Adaptive Server is unavailable or does not exist
    OS error 111, "Connection refused"
There was a problem connecting to the server

实际上几个月前我已经成功安装了,但老实说我不知道我做了什么,不幸的是我不得不格式化我的机器,所以我的问题是我不能再这样做了。我想我的问题是在我的dblibFreeTDS之间,但找不到我做错了什么。提前谢谢你的帮助。
ubuntu:14.04版本
php版本5.5.9-1ubuntu4.2

最佳答案

当为-S使用tsql标志时,需要在freetds.conf文件中指定服务器节的名称。在您的文件中,您定义了名为egServer50localhost的服务器。如果要直接使用IP地址,必须使用-H标志和-p标志,而不是-S标志。

关于php - 使用FreeTDS库通过Zend Framework连接MSSQL Server,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24541148/

10-12 02:41