ODBC driver (MySQL) Install and Setup on Ubuntu 16.04

I am writing this documentation after having spent a couple days trying to figure this out.

  • Install some Ubuntu packages

apt install unixodbc odbcinst

Why? If you don’t have unixodbc you will not be able to use the isql command, and without odbcinst you will get this lovely output when trying to install the driver:

error while loading shared libraries: libodbcinst.so.2: cannot open shared object file: No such file or directory

So be a lamb and install those packages. 😉

  • Download the MySQL ODBC Connector archive

wget https://dev.mysql.com/get/Downloads/Connector-ODBC/5.3/mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-64bit.tar.gz

(If you want to get a different version get the link from here: https://dev.mysql.com/downloads/connector/odbc/)

  • Extract the archive

tar -xvf mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-64bit.tar.gz

  • Copy the driver files

cp mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-64bit/lib/libmyodbc5* /usr/lib/x86_64-linux-gnu/odbc/

  • Install the driver

mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-64bit/bin/myodbc-installer -d -a -n “mysql” -t “DRIVER=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5w.so;”

  • Check some configs

There are two files that we care about:

/etc/odbcinst.ini –> Where the ODBC driver is defined (This file should already be created at this point)


/etc/odbc.ini –> Where the Database connection is defined (This one can be created manually with your favorite text editor)

Description=MySQL cool database

Make sure that the driver handle in the obcdinst.ini file ([mysql]) matches the name of the driver in the odbc.ini file (Driver=mysql).

The ‘DSN’ in the obdc.ini file is merely the handle of the connection, which you can use like this:

isql -v DSN

So if your DSN is ‘cool_database’ you would do:

isql -v cool_database

… and if it works you should end up at something like this:

| Connected!                             |
|                                                |
| sql-statement                          |
| help [tablename]                     |
| quit                                          |
|                                                 |




Why was I bothering with this? To get the Zabbix ODBC Item working! 😉


About: techtalk

4 thoughts on “ODBC driver (MySQL) Install and Setup on Ubuntu 16.04”

  1. Thank you for this. When trying to install the driver it keeps saying command not found 🙁

    mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-64bit/bin/myodbc-installer -d -a -n “mysql” -t “DRIVER=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5w.so;”

    Even when I cd into the folder where the myodbc-installer is… its weird

  2. Getting the error message when I trying to install driver..

    mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-64bit/bin/myodbc-installer: error while loading shared libraries: libodbc.so.2: cannot open shared object file: No such file or directory”

Leave a Reply

Your email address will not be published. Required fields are marked *