Home >Backend Development >PHP Tutorial >PHP installs dblib extension and the specific steps to connect to mssql

PHP installs dblib extension and the specific steps to connect to mssql

黄舟
黄舟Original
2017-03-04 14:15:442518browse

The following editor will bring you an article on the specific steps to install dblib extension in PHP and connect to mssql. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look.

1. Install freetds first and then modify the configuration file.

Do not install version 0.82, otherwise it will report a compilation failure.

Compile Failure With freetds0.82

Go to the freetds directory to compile and install

./configure --prefix=/usr/local/freetds --enable-msdblib --enable-sybase-compat   --disable-threadsafe
make
make install

2. Then install mssql

Go to the directory to compile and install

/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-config --with-mssql=/usr/local/freetds
make
make install

3. Install dblib

Go to the directory to compile and install

/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. Modify php.ini

extension=mssql.so
extension=pdo_dblib.so

tsql client connection command

/usr/local/freetds/bin/tsql -H 192.168.1.100 -p 1433 -U sa -P 123456 -D user

Modify the configuration file

/usr/local/freetds/etc/freetds.conf 配置文件位置
tds version = 8.0 //修改
client charset = UTF8 //新增

If you cannot connect to the database, check the version and set tds version = 8.0 in the global option in /usr/local/freetds/etc/freetds.conf

If the result is garbled, change /usr/local/freetds/etc/freetds.conf and add a client charset = UTF8 to global

Adaptive Server is unavailable or does not exist ” error connecting to SQL Server from PHP It’s caused by not adding a port

You need to add a port or you can’t connect

'dblib:host=192.168.8.888:1433; dbname=xxxx'

The above are the specific steps for installing dblib extension in PHP and connecting to mssql. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn