2

我正在配置 ODBC.ini 文件以从 Debian 服务器连接到远程数据库。我的背景主要是 PHP 和 MySQL,所以设置 ODBC 对我来说是新的,希望能提供任何帮助。我的理解是每个DSN都需要在ODBC.ini文件中配置,我已经有了这些信息。

;---------------------------------------------------------------------------
; IBM INFORMIX ODBC Sample File
;
; File:     odbc.ini
;
;---------------------------------------------------------------------------
[ODBC Data Sources]
Infdrv1=IBM INFORMIX ODBC DRIVER
Infdrv2=IBM INFORMIX ODBC DRIVER
;
; Define ODBC Database Driver's Below - Driver Configuration Section
;
[Infdrv1]
Driver=/extra/informix/lib/cli/iclit09b.so
Description=IBM INFORMIX ODBC DRIVER
Database=stores_demo
LogonID=odbc
pwd=odbc
Servername=ids_server1
[Infdrv2]
Driver=/extra/informix/lib/cli/iclis09b.so
Description=IBM INFORMIX ODBC DRIVER
Database=stores_demo
LogonID=odbc
pwd=odbc
Servername=ids_server2
CursorBehavior=0
CLIENT_LOCALE=en_us.8859-1
DB_LOCALE=en_us.8859-1
TRANSLATIONDLL=/extra/informix/lib/esql/igo4a304.so
;
; UNICODE connection Section
;
[ODBC]
;uncomment the below line for UNICODE connection
;UNICODE=UCS-4
;
; Trace file Section
;
Trace=0
TraceFile=/tmp/odbctrace.out
InstallDir=/extra/informix
TRACEDLL=idmrs09a.so

但是,我想知道在客户端完成配置后是否有测试连接性的实用程序或方法。似乎有很多关于如何在 Windows 上执行此操作的信息,而在 Linux 上则更少。任何帮助表示赞赏。

4

1 回答 1

8

之前,只是一个评论。如果您想使用PHP 访问 Informix,则存在一个 PDO …… 您可以在此处此处或此处找到如何安装/配置它的提示PHP and Informix on Debian - how to install/configure the PDO

我使用通过 unixODBC rpm 获取它的“isql”命令(我使用 opensuse 发行版)。
官方网站:http
://www.unixodbc.org/ 也有一些解释如何使用它。
你可以找到Informix手册的更新信息::http: //pic.dhe.ibm.com/infocenter/informix/v121/topic/com.ibm.odbc.doc/ids_odbc_057.htm

要设置 Informix 访问,我只需:

  1. 设置informix变量(你需要安装csdk)
export INFORMIXDIR=/opt/informix  
export INFORMIXSERVER=ifxtest
export INFORMIXSQLHOSTS=$INFORMIXDIR/etc/sqlhosts
export PATH=$INFORMIXDIR/bin:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$INFORMIXDIR/lib:$INFORMIXDIR/lib/cli:$INFORMIXDIR/lib/esql:$INFORMIXDIR/lib/tools
  1. 使用所需的配置创建 odbc.ini。
    设置 DNS 名称(示例中为 Infdrv1)
    定义驱动程序到安装 csdk 的路径 定义数据库、服务器名、登录名/密码(如果需要)
  2. 导出指向您的 odbc.ini 文件的 ODBCINI 变量,或为特定用户创建 $HOME/.odbc.ini。
  3. 尝试连接到数据库执行:isql <dns_name> <user> <passwd>

在上面的所有配置之后,这是我的测试:

ifxdba1  cinacio@jdi:~
$ isql dba1 informix xxxxxx
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> select first 1 * from systables;
+---------------------------------------------------------------------------------------------------------------------------------+---------------------------------+------------+------------+--------+-------+---------+-----------------------+-----------+------------+--------+----------+-----------------------+------------+------------+-------+---------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+--------------------------+------------+----------------+-----------+----------+
| tabname                                                                                                                         | owner                           | partnum    | tabid      | rowsize| ncols | nindexes| nrows                 | created   | version    | tabtype| locklevel| npused                | fextsize   | nextsize   | flags | site                                                                                                                            | dbname                                                                                                                          | type_xid   | am_id      | pagesize   | ustlowts                 | secpolicyid| protgranularity| statchange| statlevel|
+---------------------------------------------------------------------------------------------------------------------------------+---------------------------------+------------+------------+--------+-------+---------+-----------------------+-----------+------------+--------+----------+-----------------------+------------+------------+-------+---------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+--------------------------+------------+----------------+-----------+----------+
| systables                                                                                                                       | informix                        | 1048580    | 1          | 500    | 26    | 2       | 262                   | 2013-06-05| 65539      | T      | R        | 21                    | 16         | 16         | 0     |                                                                                                                                 |                                                                                                                                 | 0          | 0          | 2048       | 2013-06-05 21:28:50.00000| 0          |                |           |          |
+---------------------------------------------------------------------------------------------------------------------------------+---------------------------------+------------+------------+--------+-------+---------+-----------------------+-----------+------------+--------+----------+-----------------------+------------+------------+-------+---------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------+------------+------------+------------+--------------------------+------------+----------------+-----------+----------+
SQLRowCount returns -1
1 rows fetched
SQL>

我的opensuse上安装的UnixODBC信息...

cinacio@jdi:~
$ rpm -qi  unixODBC
Name        : unixODBC
Version     : 2.2.12
Release     : 219.1.1
Architecture: x86_64
Install Date: Tue 15 Oct 2013 08:18:36 AM BRT
Group       : Productivity/Databases/Tools
Size        : 1700974
License     : GPL-2.0+ ; LGPL-2.1+
Signature   : RSA/SHA256, Sat 26 Jan 2013 01:57:06 PM BRST, Key ID b88b2fd43dbdc284
Source RPM  : unixODBC-2.2.12-219.1.1.src.rpm
Build Date  : Sat 26 Jan 2013 01:56:38 PM BRST
Build Host  : build22
Relocations : (not relocatable)
Packager    : http://bugs.opensuse.org
Vendor      : openSUSE
URL         : http://www.unixodbc.org/
Summary     : ODBC driver manager with some drivers included
Description :
UnixODBC aims to provide a complete ODBC solution for the Linux
platform. Further drivers can be found at http://www.unixodbc.org/.



Authors:
--------
    Peter Harvey <pharvey@codebydesigns.com>
    Nick Gorham <nick@easysoft.com>
Distribution: openSUSE 12.3
于 2013-11-08T00:37:05.903 回答