我正在尝试连接 MSSQL Server,但遇到了一些困难。首先,我的服务器抛出以下错误:
Message: SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 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
其实几个月前我已经安装成功了,但是老实说我不知道我做了什么,不幸的是我不得不格式化我的机器,所以我的问题是我做不到再次。我认为我的问题出在我的 dblib
和 FreeTDS
之间,但找不到我做错了什么。在此先感谢您的帮助。
Ubuntu:14.04 PHP 版本 5.5.9-1ubuntu4.2
最佳答案
当为 tsql
使用 -S
标志时,您需要在 freetds.conf
文件中指定服务器部分的名称.在您的文件中,您定义了名为 egServer50
和 localhost
的服务器。如果您想直接使用 IP 地址,则必须同时使用 -H
标志和 -p
标志,而不是 -S
旗帜。
关于php - 使用 FreeTDS 库通过 Zend Framework 连接 MSSQL Server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24541148/