因为环境需要,linux+php连接mssql
安装加载freetds模块过程省略网上很多
在/etc/profile
中加入export PATH="$PATH:/usr/local/freetds/bin"
#echo "/usr/local/freetds/lib" >> /etc/ld.so.conf
source /etc/profile
#ldconfig
#ldconfig
再配置freetds
/usr/local/freetds/etc
/usr/local/freetds/etc
[root@xafcbackup ~]# cat /usr/local/freetds/etc/freetds.conf
[global]
# TDS protocol version
; tds version = 4.2
# 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
host = 51.102.121.217
port = 1433
tds version = 8.0
client charset = GBK
[global]
# TDS protocol version
; tds version = 4.2
# 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
host = 51.102.121.217
port = 1433
tds version = 8.0
client charset = GBK
[root@xafcbackup etc]# cat /data/caijishuju/t.php
<?php
$conn=mssql_connect("51.102.121.217","sa", xaj!@34);
<?php
$conn=mssql_connect("51.102.121.217","sa", xaj!@34);
//test
if($conn)
{
echo "ok";
} else
{
echo "no";
}
if($conn)
{
echo "ok";
} else
{
echo "no";
}
?>
程序配置文件连接的是定义的名称而不是ip否则不能连接!
参考http://coralzd.blog.51cto.com/90341/525106
参考http://coralzd.blog.51cto.com/90341/525106
本文转自 liang3391 51CTO博客,原文链接:http://blog.51cto.com/liang3391/664505