linux odbc配置,Linux/UNIX ODBC 配置全过程总结

#  some materials about unixodbc

#http://www.easysoft.com/develope ... linux.html#unixodbc most worthy to read

#Chen peng MSN:peng.ch@hotmail.com 2006-4-28

# The unixODBC source distribution is a gzipped tar file on

# Uncompress it in the dir /usr/local and then untar the resultant file.

gunzip unixODBC-2.2.12.tar.gz

tar -xzvf unixODBC-2.2.12.tar

./configure --prefix=/usr/local/unixODBC-2.2.12 --includedir=/usr/include --libdir=/usr/lib -bindir=/usr/bin --sysconfdir=/etc

# create an ODBC driver template file and run odbcinst. filename : template_file

/*

In this case your template file must contain the Driver andDescription attributes at a minimum and optionally the Setup attributee.g.

[DRIVER_NAME]

Description = description of the ODBC driver

Driver = path_to_odbc_driver_shared_object

Setup = path_to_driver_setup_shared_object

e.g:

SkyKonnect:/ # cat /usr/local/etc/odbcinst.ini

[MySQL]

Description     = ODBC for MySQL

Driver          = /usr/lib/libmyodbc3.so

Setup           = /usr/local/lib/libodbcmyS.so

FileUsage       = 2

UsageCount      = 2

*/

odbcinst -f template_file -d -i

# You can list all installed ODBC drivers with:

odbcinst  -s -q

/*

SkyKonnect:/usr/local/unixODBC-2.2.11/ODBCConfig # odbcinst  -s -q

[myodbc3]

*/

# you can locate the odbcinst.ini file used to defined drivers as below If unixODBC is already installed :

odbcinst -j

/*

SkyKonnect:/usr/local/unixODBC-2.2.11/ODBCConfig # odbcinst  -j

unixODBC 2.2.11

DRIVERS............: /usr/local/etc/odbcinst.ini

SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini

USER DATA SOURCES..: /root/.odbc.ini

*/

/** Edit the SYSTEM or USER DSN ini file ( odbc.ini or .odbc.ini) and add a data source using the syntax:

[ODBC_datasource_name}

Driver = driver_name

Description = description_of_data_source

attribute1 = value

.

.

attributen = value*

*/

/*

SkyKonnect:/ # cat /root/.odbc.ini

[myodbc3]

Driver          = /usr/lib/libmyodbc3.so

Description     = MyODBC 3.51 Driver DSN

SERVER          = 192.168.1.9

PORT            = 3306

USER            = root

Password        = root

Database        = wapmax

OPTION          = 3

SOCKET          =

*/

# You can list user and system data sources with:

odbcinst  -q -s

/*

SkyKonnect:/usr/local/unixODBC-2.2.11/ODBCConfig # odbcinst  -q -s

[myodbc3]

*/

# The format of isql's command line for testing connection is:

isql -v DSN_NAME db_username db_password

/*

SkyKonnect:/ # isql myodbc3 root root

+---------------------------------------+

| Connected!                            |

|                                       |

| sql-statement                         |

| help [table]

| quit                                  |

|                                       |

+---------------------------------------+

SQL>

*/

#Tracing ODBC calls

/*

The unixODBC driver manager can write a trace of call ODBC calls made to a file.

This can be a very useful debugging aid but it should be remembered that tracing will slow your application down.

Locate your odbcinst.ini file  and add a section to this file like:

[ODBC]

TraceFile = /tmp/sql.log

Trace = Yes

You can use any file for the TraceFile argument and it does not need to pre-exist.

The permissions on the odbcinst.ini may be such that you need to be the root user.

*/

[本帖最后由 云杉上的蝴蝶 于 2008-11-12 23:46 编辑]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值