3

I try to connect sqlserver with pdo dblib in VM centos6 x64. runing the php page below:

try{
$dsn = "dblib:host=192.168.5.101;dbname=webfilter";
$user = "myuser";
$password = "mypass";
$db = new PDO($dsn, $user, $password);
echo "connection successfull";
}
catch(Exception $e)
{
echo "error message:".$e->getMessage();
}

and this page prints: "error message:SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)" What does it mean ? I make simple search in net but not clear solution and none of them helped my my problem is not about connection string.

and here some of phpinfo contents: PDO drivers: dblib, mysql, sqlite

Flavour: freetds

(I can ping and log in to sql server in windows host)

EDITED tried connect with tsql command:

root@company-gwfilter:~ # tsql -S 192.168.5.101 -U myuser -P 'mypass' -L webfilter
locale is "en_US.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

At least I can see there is a problem now.. but cant find what it is.. I checked port sqlserver 1433, and I edit freetds.conf with this host settings but still same error

kgd
  • 1,666
  • 2
  • 11
  • 15

1 Answers1

0

I solved my issue, change sql server instance port: SQL Server Network Configuration -> TCP/IP (enable it) -> IP Addresses -> IPAll -> TCP Dynamic Ports. And edit freetds.conf in Linux with same port then connection is successfull.

I hope this helps who suffer same problem.