我正在尝试通过在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的尝试是:
此代码在我的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 = 0xffff # Command and connection timeouts ; timeout = 10 ; connect timeout = 10 # If you get out-of-memory errors, it may mean that your client # is trying to allocate a huge buffer for a TEXT field. # Try setting 'text size' to a more reasonable limit text size = 64512 # A typical Microsoft server [FreeTDS] host = ssssssssss.database.windows.net port = 1433 tds version = 9.1 client charset = UTF-8
/etc/odbc.ini:
[TS] Description = "test" Driver = FreeTDS Server = sssssssssssss.database.windows.net Port = 1433 Database = db_xxxxxxx_xxx_xxx
/etc/odbcinst.ini
[FreeTDS] Description = tdsodbc Driver = /usr/lib/odbc/libtdsodbc.so
对此混乱的任何帮助将不胜感激。我显然在这一点上迷路了。谢谢!