1、先安裝freetds 然後修改配置文件
不要裝0.82版本,會報編譯失敗
Compile Failure With freetds0.82
進到freetds目錄下編譯安裝
./configure --prefix=/usr/local/freetds --enable-msdblib --enable-sybase-compat --disable-threadsafe
make
make install
2、再裝mssql
進到目錄下編譯安裝
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-mssql=/usr/local/freetds
make
make install
3、再裝dblib
進到目錄下編譯安裝
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-dblib=/usr/local/freetds
make
make install
4、修改php.ini
extension=mssql.so
extension=pdo_dblib.so
tsql客戶端連接的命令
/usr/local/freetds/bin/tsql -H 192.168.1.100 -p 1433 -U sa -P 123456 -D user
修改配置文件
/usr/local/freetds/etc/freetds.conf 配置文件位置
tds version = 8.0 //修改
client charset = UTF8 //新增
如果連不上數據庫,就檢查一下版本,將/usr/local/freetds/etc/freetds.conf中global選項中tds version = 8.0
如果查到的結果是亂碼,更改/usr/local/freetds/etc/freetds.conf將global中添加了一條client charset = UTF8
Adaptive Server is unavailable or does not exist” error connecting to SQL Server from PHP 是沒加端口引起的
要加端口不然連不上
'dblib:host=192.168.8.888:1433;dbname=xxxx'