ODBC分组的安装可以通过手动编译方式也可以通过rpm分组方式进行,但是本文中选择rpm分组的安装方式:
[root@boserver odbc]# ls -l
共计1656
- rw-r-- r--1root root 2981392014-08-27 unixodbc-2.2.11-10.el5.x86 _ 64.rpm
- rw-r---r---1 root root 8117852014-08-27 unixodbc-devel-2.2.11-10.el5.x86 _ 64.rpm
- rw-r---r---1 root root 5676592014-08-27 unixodbc-libs-2.2.11-10.el5.x86 _ 64.rpm
[ root @ boserverodbc ] # rpm-ivhunixodbc-2.2.11-10.el5.x86 _ 64.rpm unixodbc-devel-2.2.11-10.el5
warning : unixodbc-2.2.11-10.el5.x86 _ 64.rpm : header v3 dsasignature 3360 nokey,key ID 37017186
preparing . # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 100 %
1: unixodbc-libs # # # # # # # # # # # # # # # # # # # # # # # # 33 %
2: unixodbc # # # # # # # # # # # # # # # # # # # # # # # 67 %
3: unixodbc-devel # # # # # # # # # # # # # # # # unixodbc-devel # # # # [ 100 % ]
2.FreeTDS介绍
此工具是用于在Linux上连接MSSQL Server和Sybase的免费ODBC驱动程序。
freetdsisasetoflibrariesforunixandlinuxthatallowsyourprogramstonativelytalktomicrosoftsqlserverandsybasedatabases。
技术研究,freetdsisanopensourceimplementationofthetds (tabular datastream ) )。 protocolusedbythesedatabasesfortheirownclients.itsupportsmanydifferentflavorsoftheprotocolandthreapistoacccessit.addition ation aresuchasperlandPHP,providingaccessfromthoselanguagesaswell。
ifyouarelookingforajavaimplementation,wereferyoutothejtdsprojectonsourceforge。
freetdshasmanypossibleuses.ithasbeenusedbyunix/linuxwebserverstopresentdatastoredinsqlservertotheweb toimportdataintosqlserverfromaunixsource,andtoprovidedatabaseaccessonplatforms (suchasrealtimesystems ) thave no native drive
thefreetdsclibrariesareavailableunderthetermsofthegnulgpllicense.consult copying.libinthedistributionfordetails。
下载并安装FreeTDS。
wget FTP ://FTP.freetds.org/pub/freetds/stable/freetds-stable.tgz
tar -zxvf freetds-stable.tgz
cd freetds-0.91/
./configure-- prefix=/usr/local/freetds---with-tdsver=8.0---enable-msdblib
生成安装
配置unixODBC和FreeTDS
4.1在unixodbc中注册FreeTDS驱动程序
在/etc/odbcinst.ini中添加以下:
#驱动程序来自from freetds package
# setup from FreeTDS package
[FREETDS]
escription=odbcoffreetdsformssql 2000
driver=/usr/local/freetds/lib/libtdsodbc.so
setup=/usr/local/freetds/lib/lib TDS.so
FileUsage=1
4.2将特定数据库的访问信息添加到freetds配置文件
修改/usr/local/freetds/etc/freetds.conf,并在末尾添加以下信息:
[MySQL服务器
host=192.168.0.5
端口=1433
TDS版本=8.0
client charset=UTF-8
测试配置是否成功安装:
[root@boserver不安的冬天]# /usr/local/freetds/不安的冬天/tsql -S MYSQLSERVER -U mytest
密码:
locale is 'zh_CN.UTF-8 '
locale charset is 'UTF-8 '
using default charset 'UTF-8 '
1
2退出
4.3修正/etc/odbc.ini
[mydsn]
Driver=FREETDS
description=SQL服务器
servername=MySQL服务器
UserName=
Password=
Database=mydb
测试:
[root@boserver令人不安的冬日]# isql mydsn username password -v
请参见--------------------------------------------------------- -
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
请参见------------------------------------------------------- -
SQL quit
[root@boserver不安的冬日]#
5 .这样就完成了ODBC数据源的配置。