How to setup ODBC in Mac (unixODBC)

Prerequisite

To use ODBC drivers on Mac, you need to install unixODBC. Please follow the instructions below to install unixODBC.

Homebrew

First, install homebrew which is required to install unixODBC.

unixODBC

Then install unixODBC with brew command like below.

brew install unixodbc

Configuration Files

On macOS, there are two configuration files that need to be edited. The first configuration file is odbcinst.ini, which holds ODBC drivers information. The second file is odbc.ini which holds information required to connect to databases such as host, user name, password, etc and is defined at System level.

  • odbcinst.ini (for ODBC drivers)
  • odbc.ini (for Database connection i.e. DSN)

Configuration Files Location

You can use below command to find the location of your configuration files

odbcinst -j   
unixODBC 2.3.9
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /Users/hidetakakojima/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

So above example, it says Drives are defined in /usr/local/etc/odbcinst.ini and System DSN is defined in /usr/local/etc/odbc.ini

Install ODBC Drivers

Once you setup unixODBC, you can install ODBC drivers. The below list shows some of the examples.