mysql odbc.ini_关于unixodbc中odbc.ini和odbcinst.ini的介绍
关于unixodbc中odbc.ini和odbcinst.ini的介绍
unixODBC without the GUI
Or
everything you wanted to know about odbcinst but were afraid to ask
PurposeA lot of people are using unixODBC but for a number of reasons are not building the GUI configuration and testing tools (ODBCConfig and DataManager). This document is aimed at these people and hopes to explain what you need to do and when to do it.
What's a ini file ?ODBC first appeared within Windows 3.0. At this time Windows used .ini files to contain configuration information. These are text files containing the following layout [section1]
entry1 = value
entry2 = value
[section2]
entry1 = value
entry2 = value
...With the advent of Windows NT these ini files have been replaced by the registry, but the API to access them in ODBC has remained the same. Windows has two function in odbcinst.dll that allow applications and drivers to query and modify these files, SQLGetPrivateProfileString and SQLPutPrivateProfileString.
As part of unixODBC's aim of reproducing the ODBC environment on non Windows platform's the ini files and libodbcinst provide the same format and functionality.
System versus UserODBC distingushes between two types of ini files. System ini files are designed to be accessable but not modifable by any user, and user files are private to a particular user, and may be modified by that user.
The system files are odbcinst.ini and odbc.ini (note no leading dot), and the user file is ~/.odbc.ini in each user's home directory (note leading dot).
The system file odbcinst.ini contains information about ODBC drivers available to all users, and the odbc.ini file contains information about DSN's available to all users. These "System DSN's" are useful for application such as web servers that may not be running as a real user and so will not have a home directory to contain a .odbc.ini file.
A good example of this is Apache and PHP with ODBC support. When the http server is first started it calls SQLAllocEnv as root. it then at a later time changes to the specified user (in my case nobody) and calls SQLConnect. If the DSN's was not a system DSN then this fails.
FILEDSN'sODBC 3 also has a third sort of DSN, a file DSN. These store the connection information in a file that may be accessable to anyone. unixODBC does not at this time support FILEDSN's but it will when I get around to it. They are useful things but of less use to UNIX's than NT. Because of the MS view that everyone should have Windows on their desk, each workstation will have it's own registry with it's own set of system and user DSN's that can not be used by other workstations. File DSN's are a fix to allow the information to be stored in a central server that is accessable to all the workstations.
Why not vi ?All the configuration files needed by unixODBC are plain text files, so there is no reason that you can not use your favorite text editor to setup the files.
However since beta 1.6 the location of the system files odbcinst.ini and odbc.ini are determined by the configure script. The default location is /usr/local/etc, and if a prefix is specified the location is {prefix}/etc. The location of the etc path can be broken out of the normal prefix tree by specifing --sysconfdir=DIR, so the following will expect the system files to be in the same location as pre 1.6 builds../configure --sysconfdir=/etcThe upshot of all this is that if you use odbcinst to configure the files you can be sure that the same path to the files will be used as are used by the driver manager, so the modifications will take effect.
What goes into them ?Ok now we know a bit of the history of ini files and ODBC so now we need to get to the bit that is actually of use. What you put in them.
odbcinst.iniThis contains a section heading that provides a name for the driver, so for the example below PostgreSQL to indicate a Postgres driver. The following lines contain a description and then the important bits. The Driver and Setup paths point to the ODBC driver and setup libs. The setup lib is used when you click on Add in ODBCConfig to add a new DSN, but as this document is about not using the GUI tools, this is not that important for us. Far more important is the Driver entry (vital in fact) This is the library that the driver manager will dynamicaly load when SQLConnect or SQLDriverConnect is called for that DSN. If this points to the wrong place the DSN will not work. If the dlopen() fails the DSN will not work. The fileusage entry is added by the odbcinst program, so if you are using a text editor, you will need to add it yourself. [PostgreSQL]
Description = PostgreSQL driver for Linux & Win32
Driver = /usr/local/lib/libodbcpsql.so
Setup = /usr/local/lib/libodbcpsqlS.so
FileUsage = 1
templatesodbcinst expects to be supplied with a template file. If you are adding a driver for the above entry the template file would contain the following [PostgreSQL]
Description = PostgreSQL driver for Linux & Win32
Driver = /usr/local/lib/libodbcpsql.so
Setup = /usr/local/lib/libodbcpsqlS.soand you would invoke odbcinst with the following arguments, assuming that you have created a file template_file with the above entries in. odbcinst -i -d -f template_fileThe args to odbcinst are as follows
-i install
-d driver
-f name of template file
ThreadsSince 1.6 if the driver manager was built with thread support you may add another entry to each driver entry. For example [PostgreSQL]
Description = PostgreSQL driver for Linux & Win32
Driver = /usr/local/lib/libodbcpsql.so
Setup = /usr/local/lib/libodbcpsqlS.so
Threading = 2This entry alters the default thread serialization level. More details can be found in the file DriverManager/__handles.c in the source tree.
[.]odbc.iniThe contents of the odbc.ini files are a bit more complicated, but they follow just the same format as the odbcinst.ini entries. These are complicated by each driver requiring different entries. The entries for all the drivers supplied with the distribution are included bellow for reference. The entries may be added in the same way using odbcinst, or a text editor. A sample entry to match the above driver could be [PostgreSQL]
Description = Test to Postgres
Driver = PostgreSQL
Trace = Yes
TraceFile = sql.log
Database = nick
Servername = localhost
UserName =
Password =
Port = 5432
Protocol = 6.4
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
ConnSettings =And this may be written to a template file, and inserted in the ini file for the current user by odbcinst -i -s -f template_fileThe individual entries of course may vary.
The Driver line is used to match the [section] entry in the odbcinst.ini file and the the Driver line in the odbcinst file is used to find the path for the driver library, and this loaded and the connection is then established. It's possible to replace the driver entry with a path to the driver itself. This can be used, for example if the user can't get root access to setup anything in /etc (less important now because of the movable etc path). For example[PostgreSQL]
Description = Test to Postgres
Driver = /usr/local/lib/libodbcpsql.so
Trace = Yes
TraceFile = sql.log
Database = nick
Servername = localhost
UserName =
Password =
Port = 5432
Protocol = 6.4
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
ConnSettings =
TemplatesThe templates for the included drivers are...
Postgress[PostgreSQL]
Description = Test to Postgres
Driver = PostgreSQL
Trace = Yes
TraceFile = sql.log
Database = nick
Servername = localhost
UserName =
Password =
Port = 5432
Protocol = 6.4
ReadOnly = No
RowVersioning = No
ShowSystemTables = No
ShowOidColumn = No
FakeOidIndex = No
ConnSettings =
Mini SQL[Mini SQL]
Description = MiniSQL
Driver = MiniSQL
Trace = No
TraceFile =
Host = localhost
Database =
ConfigFile =
MySQL[MySQL-test]
Description = MySQL test database
Trace = Off
TraceFile = stderr
Driver = MySQL
SERVER = 192.168.1.26
USER = pharvey
PASSWORD =
PORT = 3306
DATABASE = test
NNTP driver[nntp Data Source]
Description = nntp Driver
Driver = nntp Driver
Trace = No
TraceFile =
Host = localhost
Database =
Port =
FreeTDS driverDriver = TDS
Description = Northwind sample database
Trace = No
Server = 192.168.1.25
Database = Northwind
UID = sa
Sybase SQL Anywhere 5.0Thanks Greg. [Sybase SQL Anywhere 5.0]
Driver=Sybase SQL Anywhere 5.0
Description=Sybase SQL Anywhere 5.0 ODBC Driver
Userid=dba
Password=sql
DatabaseFile=sademo.dbHopefully this will be of some use to someone... Nick Gorham
mysql odbc.ini_关于unixodbc中odbc.ini和odbcinst.ini的介绍相关推荐
- linux服务器odbc在哪看,在Linux上寻找odbc.ini和odbcinst.ini文件的良好文档
我在Debian上使用FreeTDS将PHP驱动的网站连接到MS-sql Server 2005数据库. 我可以给配置文件的解释: /etc/odbc.ini 保存连接到数据库的处理程序(例如PHP) ...
- 已安装oracle客户端odbc驱动,Oracle Instant Client ODBC 安装说明
安装 Oracle Instant Client Basic 和 Basic Light Instant Client ODBC 要求安装 Oracle Instant Client Basic 或 ...
- c语言odbc编程,c语言之odbc编程指南c语言之odbc编程指南.doc
c语言之odbc编程指南c语言之odbc编程指南 ?摘要本文在介绍了ODBC(开放性数据库连接,Open? DataBase? Connectivity)运行机制的基础上,着重讨论了VisualC++ ...
- c语言sqlserver进行odbc编程,c语言之odbc编程指南.doc
c语言之odbc编程指南 ?摘要本文在介绍了ODBC(开放性数据库连接,Open? DataBase? Connectivity)运行机制的基础上,着重讨论了VisualC++2.0下利用ODBCAP ...
- mysql的odbc连接字符串_MySQL :: linux ODBC连接mysql
linux ODBC连接mysql Posted by: Junquan Liu Date: August 28, 2013 11:38PM 想通过oracle连接mysql,根据网上的指引,先安装u ...
- jdbc odbc java mysql数据库连接_Java数据库连接之配置ODBC数据源
java使用JDBC-ODBC桥接连接SQLServer数据库需要配置ODBC数据源,配置步骤如下: 1.进入控制面板,找到管理工具 2.看到ODBC数据源,有64位和32位的,如果你的数据库是64位 ...
- mysql odbc c语言_C语言ODBC操作MySQL数据库(示例代码)
数据库及其编程API来源于不同的背景,开发人员可以从众多的数据库中选择一种,每种数据库都有自己的一套编程API,这就为数据库编程造成了很大的局限性.SQL是标准化数据库编程接口的一种尝试,然而各种数据 ...
- Windows 64 位 mysql 5.7以上版本包解压中没有data目录和my-default.ini和my.ini文件以及服务无法启动的解决办法以及修改初始密码的方法
Windows 64 位 mysql 5.7以上版本包解压中没有data目录和my-default.ini和my.ini文件以及服务无法启动的解决办法以及修改初始密码的方法 参考文章: (1)Wind ...
- mysql+odbc驱动安装_MySQL的ODBC驱动下载及安装及ODBC配置
点击进入mysql官网下载界面:https://dev.mysql.com/downloads/connector/odbc/ 2.安装驱动 3.配置数据源 依次找到[控制面板]-[管理工具]-[OD ...
最新文章
- Map集合中value()方法与keySet()、entrySet()区别 ——转载
- html酒鬼酒网站制作,酒鬼酒
- HTML课堂笔记02-21
- 近邻取样插值和其速度优化
- pxe方式安装gentoo
- 在dreamweaver mx中它只能对html文件可以进行编辑,【职称计算机考试网页制作历年试题及答案二】- 环球网校...
- 【面向对象】基本概念
- 12C RAC for ASM添加磁盘步骤
- SqlServer查询语句中用到的锁
- 留学计算机美国硕士,美国硕士留学计算机专业有哪些名校推荐下?
- java找三个数最大_用Java程序找最大的数字(4)
- Amazon Lambda支持以简单队列服务作为事件源了
- python docx 表格_python-docx表格添加和删除数据
- jquery 选择器 逗号
- spark job stage task概念与区分
- 在django项目中使用django-ckeditor
- 三实系统地址是什么意思_终于明白!火灾报警系统的余量应该如何设置?地址数又是什么?...
- 【解决办法】C++2015安装不上,说是要安装Windows6.1-KB2999226-x64.msu这个补丁,下载下来怎么安装!...
- 神经网络自适应反馈控制设计
- Java中观察者模式与委托的对比
热门文章
- MATLAB GUI如何创建Callback函数
- (一看就懂)傅里叶变换、拉普拉斯变换、Z变换、卷积的经典文章汇总
- Keras】基于SegNet和U-Net的遥感图像语义分割
- MySQL流浪记(三)—— Linux安装MySQL数据库5.7.30(亲测有效3分钟即可)
- C++学习之路 | PTA(天梯赛)—— L3-003 社交集群 (30分) (带注释) (并查集) (精简)
- java求平均值Scanner_Scanner的一些问题
- debconf-set-selections mysql_docker 静默安装mysql
- ...android平板办公,教科书式安卓全 面屏平板:华为MatePad Pro构建智慧办公新体验...
- PID控制器改进笔记之六:改进PID控制器之参数设定
- 逆向调试雷电思路总结