我尝试连接MSSQL Server但我遇到了一些困难。首先,我的服务器抛出以下错误:
消息:SQLSTATE [HY000]无法连接:Adaptive Server不可用或不存在(严重级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
答案 0 :(得分:1)
对-S
使用tsql
标志时,您需要在freetds.conf
文件中指定服务器部分的名称。在您的文件中,您已定义了名为egServer50
和localhost
的服务器。如果要直接使用IP地址,则必须使用-H
标志和-p
标志,而不是-S
标志。