ODBC

Howto: installing ODBC and ODBC-mysql-connector

Posted on Updated on

Setting up ODBC on CentOS 6

Some of the programmers uses ODBC for connecting various database also it is easy to configure different data base server under one roof.

I use the blow method for enable in my development server.

Packages : http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/Connector-ODBC/5.2/mysql-connector-odbc-5.2.6-1.el6.x86_64.rpm

ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.2.tar.gz

Installation :

#mkdir /opt/installer ; cd /opt/installer

Download the packages to the installer dir

#tar -zxvf unixODBC-2.3.2.tar.gz
#./configure ; make ; make install

rpm -ivh --nodeps mysql-connector-odbc-5.2.6-1.el6.x86_64.rp

#vi /etc/profile
# Add the entries at the last line
SYBASE=/usr/local 
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$SYBASE/lib 
export SYBASE LD_LIBRARY_PATH

DSN File :

#cat  /usr/local/etc/odbc.ini
[MySQL01]
Driver=MySQL ODBC 5.2 ANSI Driver
  #this is the name specified in the driver file
Server=111.222.333.444
Database=mydatabasename
Port=3306
Option=3
User=mydbuser
Password=mydbpassword
UsageCount=1

[MySQL02]
Description=Installation level
Driver=MySQL ODBC 5.2 ANSI Driver
   #this is the name specified in the driver file
Server=222.33.44.555
Database=databasename
Port=3306
Option=3
User=mydbuser
Password=mydbpassword
UsageCount=1

Driver File :

#cat /usr/local/etc/odbcinst.ini
[MySQL ODBC 5.2 Unicode Driver]
Driver=/usr/lib64/libmyodbc5w.so
UsageCount=2

[MySQL ODBC 5.2 ANSI Driver]
Driver=/usr/lib64/libmyodbc5a.so
UsageCount=2

Installing drivers with DSN:

#odbcinst -i -d -f /usr/local/etc/odbcinst.ini
#odbcinst -i -s -l -f  /usr/local/etc/odbc.ini

Validate installed DSN 
#odbcinst -s -q
[MySQL01]
[MySQL02]

Connection verification:

isql -v  MySQL01
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>

Possible options for the DB setting

http://www.unixodbc.org/odbcinst.html

Detailed ODBC setup guid

http://www.unixodbc.org/unixODBCsetup.html