MYSQL-ODBC Connectivity on CentOS/RHEL/Debian/Ubuntu

MYSQL-ODBC Connectivity on CentOS/RHEL/Debian/Ubuntu

What is ODBC ??

ODBC  stands for “Open Database Connectivity”.

It  is a standard middleware API written in C-Programming Language for accessing DBMS i.e Database Management System.

It uses an ODBC driver as a translation layer among the Application & DBMS. The application is linked  with the ODBC driver manager from where it uses ODBC functions, the driver passes the query to the DBMS.

An application written using ODBC can be ported to other platforms both is client/server side.

 MYSQL-ODBC driver installation & configuration

In this post we will discuss how to install and configure mysql-odbc driver on a ubuntu 12.04 x64 server.

Here We assume you already have MySQL  Server installed & running.

At Beginning, we have to install below packages:-

unixodbc
root@ubuntu:~# apt-get install iodbc  unixodbc

MySQL odbc driver
root@ubuntu:~# apt-get install libmyodbc

Then run below command:-

root@ubuntu:~# odbcinst -j

unixODBC 2.2.14
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

After that Enter MySQL driver Information in /etc/odbcinst.ini  file as below :-

root@ubuntu:~# vim /etc/odbcinst.ini

[MySQL]
Description = MySQL driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so

Now Enter DSN information in /etc/odbc.ini  file as below

root@ubuntu:~# vim /etc/odbc.ini

[testing]
Description = Mysql database
Driver = MySQL
Server = 127.0.0.1
Database = how2installdb
UID = root
PWD = how2install

Run below command to get DSN information :-

root@ubuntu:~# odbcinst -q -s
[testing]

You can check the driver information with below command :-

root@ubuntu:~# odbcinst -q -d
[MySQL]

In order to test the driver & DSN entries you can run below command :-

root@ubuntu:~# isql testing
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>

Leave a Reply

Time limit is exhausted. Please reload the CAPTCHA.