linux odbc 数据源测试,linux操作系统配置ODBC数据源
1.安裝ODBC數據包,可以通過手工編譯的方式也可以通過rpm包的方式進行安裝,本文選擇rpm包的安裝方式:
[root@boserver odbc]# ls -l
總計 1656
-rw-r--r-- 1 root root 298139 2014-08-27 unixODBC-2.2.11-10.el5.x86_64.rpm
-rw-r--r-- 1 root root 811785 2014-08-27 unixODBC-devel-2.2.11-10.el5.x86_64.rpm
-rw-r--r-- 1 root root 567659 2014-08-27 unixODBC-libs-2.2.11-10.el5.x86_64.rpm
[root@boserver odbc]# rpm -ivh unixODBC-2.2.11-10.el5.x86_64.rpm? unixODBC-devel-2.2.11-10.el5.x86_64.rpm? unixODBC-libs-2.2.11-10.el5.x86_64.rpm
warning: unixODBC-2.2.11-10.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...??????????????? ########################################### [100%]
1:unixODBC-libs????????? ########################################### [ 33%]
2:unixODBC?????????????? ########################################### [ 67%]
3:unixODBC-devel???????? ########################################### [100%]
2.FreeTDS介紹
該工具是Linux下用于連接MSSQL Server和Sybase的免費ODBC 驅動.
FreeTDS is a set of libraries for Unix and Linux that allows your programs to natively talk to Microsoft SQL Server and Sybase databases.
Technically speaking, FreeTDS is an open source implementation of the TDS (Tabular Data Stream) protocol used by these databases for their own clients. It supports many different flavors of the protocol and three APIs to access it. Additionally FreeTDS works with other software such as Perl and PHP, providing access from those languages as well.
If you are looking for a Java implementation, we refer you to the jTDS project on SourceForge.
FreeTDS has many possible uses. It has been used by Unix/Linux webservers to present data stored in SQL Server to the web, to port SQL Server database code from NT to Unix, to import data into SQL Server from a Unix source, and to provide database access on platforms (such as realtime systems) that have no native drivers.
The FreeTDS C libraries are available under the terms of the GNU LGPL license. Consult COPYING.LIB in the distribution for details.
3.下載并安裝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
make && make install
4.配置 unixODBC和FreeTDS
4.1向unixODBC 登記 FreeTDS 驅動
在 /etc/odbcinst.ini 中添加如下內容:
# Driver from FreeTDS package
# setup from FreeTDS package
[FREETDS]
Description???? = ODBC of FreeTDS for MS SQL 2000
Driver????????? = /usr/local/freetds/lib/libtdsodbc.so
Setup?????????? = /usr/local/freetds/lib/libtds.so
FileUsage?????? = 1
4.2在 FreeTDS 的配置文件中添加指向具體數據庫的訪問信息??修改 /usr/local/freetds/etc/freetds.conf,在最后添加如下信息:????[MYSQLSERVER]??host = 192.168.0.5??port = 1433??tds version = 8.0??client charset = UTF-8????測試是否安裝配置成功:??[root@boserver bin]# /usr/local/freetds/bin/tsql -S MYSQLSERVER -U mytest??Password: ??locale is "zh_CN.UTF-8"??locale charset is "UTF-8"??using default charset "UTF-8"??1> ??2> exit???4.3修改/etc/odbc.ini ??[mydsn]??Driver????????? = FREETDS? ??Description???? = SQLServer??Servername????? = MYSQLSERVER??UserName??????? =??Password??????? =??Database??????? = mydb????測試:??[root@boserver bin]# isql mydsn username password -v??+---------------------------------------+??| Connected!??????????????????????????? |??|?????????????????????????????????????? |??| sql-statement???????????????????????? |??| help [tablename]????????????????????? |??| quit????????????????????????????????? |??|?????????????????????????????????????? |??+---------------------------------------+??SQL> quit??[root@boserver bin]# 5.至此ODBC數據源配置完成.
總結
以上是生活随笔為你收集整理的linux odbc 数据源测试,linux操作系统配置ODBC数据源的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux编译lua,Linux Cen
- 下一篇: c# ssh到linux,C#通过Sha