我正在尝试通过在Ubuntu 11.04服务器上运行的PHP连接到SQL Azure数据库。
服务器正在运行PHP版本=> 5.3.5-1ubuntu7.11。
我已经使用apt-get install多次安装了freetds-bin,freetds-common,tdsodbc,odbcinst,php5-odbc和unixodbc。我试图用SSL支持编译FreeTDS,但不确定是否成功。
此时,在尝试使用isql工具进行连接时,出现错误“ 08S01-通信链接失败”。Microsoft的一篇文章将错误解释为“在SQLDriverConnect函数完成处理之前,驱动程序与驱动程序尝试连接到的数据源之间的通信链接失败。” 对此的一些研究明确指出FreeTDS中缺乏SSL支持,但是我不清楚如何验证已启用该功能。
我将使用PHP数据对象或mssql_ *函数连接到SQL Azure数据库。我对PDO不太熟悉,但似乎PDO不一定使用ODBC?我对此还不太清楚,并且我怀疑这导致我对isql看到的与我在PHP中看到的问题无关的问题进行故障排除。isql工具的连接问题是否与PHP中的PDO或mssql_ *函数中的连接问题有关?
我最近使用PDO的尝试是:
<?php
$c = new PDO("odbc:Driver=FreeTDS;Port=1433;Server=sssssssssss.database.windows.net;Database=db_xxxxx_xxx_xxx;UID=db_xxxxx_xxx_xxx_ExternalWriter;PWD=ppppppppp");
?>
Run Code Online (Sandbox Code Playgroud)
此代码在我的Apache日志文件中生成以下错误:
[2013年12月24日星期二13:23:10] [错误] [客户端10.1.1.11] PHP致命错误:消息为'SQLSTATE [08S01]的未捕获异常'PDOException'SQLDriverConnect:20004 [unixODBC] [FreeTDS] [SQL Server]读取从服务器失败'/var/www/test/pdo.php:3\n堆栈跟踪:\ n#0 /var/www/test/pdo.php(3):PDO-> __ construct('odbc:Driver = Fre ...')\ n#1 {main} \ n在第3行的/var/www/test/pdo.php中抛出
我的/etc/freetds/freetds.conf:
[global]
# TDS protocol version
tds version = 9.1
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
dump file = /tmp/freetds.log
debug flags = …Run Code Online (Sandbox Code Playgroud)