1

I'm trying to connect with MSSQL Server but I'm having some difficulties. First, my server is throwing the following error:

Message: SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)

Well, I think I installed FreeTDS successfully, because every check I made shows me that everything is okay.

MSSQL configs:

MSSQL configs

PDO config:

PDO config

My attempt to connect:

[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"

The modules they're installed

rodrigo@thx1138 ~   [15:51:16] 
$ php -m | grep "mssql"
mssql

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

My freetds.config: http://pastebin.com/qA0XwFVD

My nmap output

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

This is my freetds settings

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

And when I try to connect through FreeTDS got the error:

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

Actually some months ago I've already made a successful installation, but to be honest don't know what I've done and unfortunately I've had to format my machine, so my problem is that I can't do it again. I think my problem is between my dblib and FreeTDS but can't find what I'm doing wrong. Thanks in advance for any help.

Ubuntu: 14.04 PHP Version 5.5.9-1ubuntu4.2

1 Answer 1

1

When using the -S flag for tsql, you need to specify the name of a server-section in your freetds.conf file. In your file, you've defined servers named egServer50 and localhost. If you want to use an IP address directly, you have to use the -H flag along with the -p flag and not the -S flag.

Sign up to request clarification or add additional context in comments.

6 Comments

Thank you for your response. In fact I was using the tsql tool wrong, but now I'm getting the this Error 20017 (severity 9): Unexpected EOF from the server OS error 115, "Operation now in progress" Error 20002 (severity 9): Adaptive Server connection failed There was a problem connecting to the server
Just to be more clear. My problem is my connection with PHP. I was trying to test my connection with tsql and noticed that I can't connect with my server.
Can you show the PHP code you're trying to connect with?
Actually not. But I'm using Zend Framework, so up there is my connection settings. But this problem will crash any part of my code where I need to use my models.
OK. Looking through my one working pdo_mssql installation, I set the host name to a freetds.conf server section also. So, you'd set resources.db.params.host to be one of the section names in your freetds.conf file, e.g. either egServer50 or localhost.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.