linux下php+freetds连接SQL server2012

linux下php+freetds连接SQL server2012

官方网站:
http://www.freetds.org
ftp://ftp.freetds.org/pub/freetds/stable/freetds-stable.tgz
http://www.freetds.org/userguide/choosingtdsprotocol.htm

参看:
https://github.com/lj2007331/lnmp
http://blog.linuxeye.com/31.html
freetds0.91
一.下载
[root@test1 ~]# wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-stable.tgz
[root@test1 ~]# pwd
/root
[root@test1 ~]# ls
freetds-stable.tgz

二.编译安装
[root@test1 ~]# yum -y install gcc gcc-c++ libxml2-devel openssl-devel pcre-devel curl-devel gd-devel bzip2-devel
[root@test1 ~]# tar -zxvf freetds-stable.tgz -C /usr/local/src/
[root@test1 ~]# cd /usr/local/src/freetds-0.91/
[root@test1 freetds-0.91]# ls
aclocal.m4    config.sub    freetds.spec     Makefile.am    src
AUTHORS       configure     freetds.spec.in  Makefile.in    tds.dox
autogen.sh    configure.ac  include          missing        TODO
BUGS          COPYING       INSTALL          mkinstalldirs  vms
ChangeLog     COPYING.LIB   install-sh       NEWS           win32
compile       depcomp       interfaces       Nmakefile
config.guess  doc           locales.conf     PWD.in
config.log    freetds.conf  ltmain.sh        README
config.rpath  FreeTDS.sln   m4               samples

下面是截取的freetds官方安装说明

How to build: Configure and make

If you've built other GNU projects, building FreeTDS is a fairly straightforward process. We have a terse and verbose description.

Note

FreeTDS is known to build with GNU and BSD make. If you encounter a large number of build errors, and your operating system's make is not GNU make (as is the case on most non-GNU/Linux systems), you may wish to install GNU make from ftp.gnu.org.

For Experts

 $ ./configure --prefix=/usr/local
        
$
make
$
make install

Table 3-1. Versions of the TDS Protocol, by Product

ProductTDS VersionComment
Sybase before System 10, Microsoft SQL Server 6.x4.2Still works with all products, subject to its limitations.
Sybase System 10 and above5.0Still the most current protocol used by Sybase.
Sybase System SQL Anywhere5.0 onlyOriginally Watcom SQL Server, a completely separate codebase. Our best information is that SQL Anywhere first supported TDS in version 5.5.03 using the OpenServer Gateway (OSG), and native TDS 5.0 support arrived with version 6.0.
Microsoft SQL Server 7.07.0Includes support for the extended datatypes in SQL Server 7.0 (such as char/varchar fields of more than 255 characters), and support for Unicode.
Microsoft SQL Server 20007.1Include support for bigint (64 bit integers), variant and collation on all fields. Collation is not widely used.
Microsoft SQL Server 20057.2Includes support for varchar(max), varbinary(max), xml datatypes and MARS[a].
Microsoft SQL Server 20087.2 (unchanged) 
Notes:
a. Multiple Active Result Sets. FreeTDS does not support MARS.

For best results, use the highest version of the protocol supported by your server. If you encounter problems, try a lower version. If that works, though, please report it to the mailing list! [1]


[root@test1 freetds-0.91]# ./configure --prefix=/usr/local/freetds --enable-msdblib --with-tdsver=8.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
... ...
config.status: executing depfiles commands
config.status: executing libtool commands

[root@test1 freetds-0.91]# make && make install
Making all in include
make[1]: Entering directory `/usr/local/src/freetds-0.91/include'
make  all-am
... ...
make[2]: Leaving directory `/usr/local/src/freetds-0.91'
make[1]: Leaving directory `/usr/local/src/freetds-0.91'

编译php freetds库支持
[root@test1 freetds-0.91]# cp include/tds.h /usr/local/freetds/include/
[root@test1 freetds-0.91]# cp src/tds/.libs/libtds.a /usr/local/freetds/lib
[root@test1 freetds-0.91]# echo /usr/local/freetds/lib/ >>/etc/ld.so.conf.d/freetds.conf
[root@test1 freetds-0.91]# ldconfig
[root@test1 freetds-0.91]# echo "export FREETDSCONF=/usr/local/freetds/etc/freetds.conf" >> /etc/profile
[root@test1 freetds-0.91]# source /etc/profile
[root@test1 freetds-0.91]# echo $FREETDSCONF
/usr/local/freetds/etc/freetds.conf
[root@test1 freetds-0.91]# ln -s /usr/local/freetds/lib /usr/local/freetds/lib64
[root@test1 freetds-0.91]# vim /usr/local/freetds/etc/freetds.conf
[root@test1 freetds-0.91]# cat /usr/local/freetds/etc/freetds.conf
#   $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory. 
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf". 

# Global settings are overridden by those in a database
# server specific section
[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

# A typical Sybase server
#[egServer50]
#    host = symachine.domain.com
#    port = 5000
#    tds version = 5.0

# A typical Microsoft server
[SQLserver2008]   #标识,可有可无
    host = 192.168.8.112
    port = 1433
    tds version = 8.0
    client charset = UTF-8


[root@test1 freetds-0.91]# echo 'PATH=$PATH:/usr/local/freetds/bin/' >>/etc/profile
[root@test1 freetds-0.91]# source /etc/profile
[root@test1 freetds-0.91]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/freetds/bin/
[root@test1 ~]# freebcp
usage:  freebcp [[database_name.]owner.]table_name {in | out} datafile
        [-m maxerrors] [-f formatfile] [-e errfile]
        [-F firstrow] [-L lastrow] [-b batchsize]
        [-n] [-c] [-t field_terminator] [-r row_terminator]
        [-U username] [-P password] [-I interfaces_file] [-S server]
  

转载于:https://www.cnblogs.com/lixuebin/p/10814477.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值