达梦数据库之配置ODBC

传包:

[root@localhost opt]# pwd

/opt

[root@localhost opt]# ls -l unixODBC-2.3.0.tar.gz

-rw-r--r-- 1 root root 1804749 10月 19 2022 unixODBC-2.3.0.tar.gz

[root@localhost opt]#

解压:

[root@localhost opt]# tar -zxvf unixODBC-2.3.0.tar.gz

unixODBC-2.3.0/

unixODBC-2.3.0/ini/

unixODBC-2.3.0/ini/iniPropertyUpdate.c

unixODBC-2.3.0/ini/iniProperty.c

unixODBC-2.3.0/ini/iniOpen.c

unixODBC-2.3.0/ini/iniCommit.c

unixODBC-2.3.0/ini/iniPropertySeekSure.c

unixODBC-2.3.0/ini/iniValue.c

......

源码安装三部曲(配置、编译、安装)

注:configure 时可以使用--prefix 参数指定安装路径,不指定使用默认安装路径/usr/local

[root@localhost opt]# cd unixODBC-2.3.0/

[root@localhost unixODBC-2.3.0]# ./configure

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for a thread-safe mkdir -p... /usr/bin/mkdir -p

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking for gawk... (cached) gawk

checking for bison... no

checking for byacc... no

checking for style of include used by make... GNU

checking for gcc... gcc

......

make && make install

输出省......

[root@localhost unixODBC-2.3.0]# odbcinst help

odbcinst: Invalid Object

**********************************************

* unixODBC - odbcinst *

**********************************************

* *

* Purpose: *

* *

* An ODBC Installer and Uninstaller. *

* Updates system files, and *

* increases/decreases usage counts but *

* does not actually copy or remove any *

* files. *

* *

* Syntax: *

* *

* odbcinst Action Object Options *

* *

* Action: *

* *

* -i install *

* -u uninstall *

* -q query *

* -j print config info *

* -c call SQLCreateDataSource *

* -m call SQLManageDataSources *

* --version version *

* *

* Object: *

* *

* -d driver *

* -s data source *

* *

* Options: *

* *

* -f file name of template.ini follows *

* this (valid for -i) *

* -r get template.ini from stdin, not *

* a template file *

* -n Driver or Data Source Name follows *

* -v turn verbose off (no info, warning *

* or error msgs) *

* -l system dsn *

* -h user dsn *

* *

* Returns: *

* *

* 0 Success *

* !0 Failed *

* *

* Please visit; *

* *

* http://www.unixodbc.org *

* [email protected] *

**********************************************

[root@localhost unixODBC-2.3.0]# odbcinst -j

unixODBC 2.3.0

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

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

FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources

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

SQLULEN Size.......: 8

SQLLEN Size........: 8

SQLSETPOSIROW Size.: 8

[root@localhost unixODBC-2.3.0]# cd /usr/local/etc/

[root@localhost etc]# ls -l

总用量 0

drwxr-xr-x 2 root root 6 10月 19 11:44 ODBCDataSources

-rw-r--r-- 1 root root 0 10月 19 11:44 odbc.ini

-rw-r--r-- 1 root root 0 10月 19 11:44 odbcinst.ini

注意这个目录:

[root@localhost bin]# pwd

/opt/dmdbms/dmdata/bin

[root@localhost bin]# ls -l libdodbc.so

-rwxr-xr-x 1 dmdba dinstall 194134 9月 20 11:10 libdodbc.so

[root@localhost etc]# cat odbcinst.ini

[DM8 ODBC DRIVER] ---注意这个名字

Description = ODBC DRIVER FOR DM8

Driver = /opt/dmdbms/dmdata/bin/libdodbc.so

注意根据情况填写,不要复制粘贴:

[root@localhost etc]# cat odbc.ini

[DM8]   ---注意这个名字

Description = DM ODBC DSN

Driver = DM8 ODBC DRIVER

SERVER = localhost

UID = SYSDBA

PWD = SYSDBA

TCP_PORT = 15236

测试:

[dmdba@localhost ~]$ disql SYSDBA/SYSDBA@localhost:15236

服务器[localhost:15236]:处于普通打开状态

登录使用时间 : 32.697(ms)

disql V8

SQL> select count(*) from test;

行号 COUNT(*)

---------- --------------------

1 857

已用时间: 159.131(毫秒). 执行号:1600.

[root@localhost etc]# su - dmdba

上一次登录: 三 10月 19 10:31:14 CST 2022 pts/0 上

[dmdba@localhost ~]$ isql dm8 -v

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

| Connected! |

| |

| sql-statement |

| help [tablename] |

| quit |

| |

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

SQL> select count(*) from test;

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

| COUNT(*) |

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

| 857 |

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

SQLRowCount returns 1

1 rows fetched

至此配置结束。

root 执行会报错,是因为 root 没有配置 LD_LIBRARY_PATH 环境变量。

社区地址:https://eco.dameng.com

猜你喜欢

转载自blog.csdn.net/duanpian_dba/article/details/127482040