Skip to content

Instantly share code, notes, and snippets.

@rgo
Created January 19, 2012 12:15
Show Gist options
  • Save rgo/1639761 to your computer and use it in GitHub Desktop.
Save rgo/1639761 to your computer and use it in GitHub Desktop.
Unixodbc configuration example with cli
#
# COPIED FROM http://www.1stbyte.com/2011/06/28/unixodbc-example-setup-on-ubuntu-lucid-with-mysql-and-postgresql/
#
# Do the obvious, install mysql an postgresql first. :)
# install unixodbc
apt-get install unixodbc unixodbc-dev libmyodbc odbc-postgresql
cd to /etc/ODBCDataSources
# setup mysql driver, make myodbc_template file
[MySQL]
Description = MySQL driver
Driver = /usr/lib/odbc/libmyodbc.so
Setup = /usr/lib/odbc/libodbcmyS.so
#inst template driver
odbcinst -i -d -f myodbc_template
# setup pg driver, make pgodbc_template file
[PostgreSQL]
Description = PostgreSQL driver for Linux & Win32
Driver = /usr/lib/odbc/psqlodbca.so
Setup = /usr/lib/odbc/libodbcpsqlS.so
#inst template driver
odbcinst -i -d -f pgodbc_template
# query available/installed drivers
odbcinst -q -d
#should list Mysql and PostgreSQL
# make sample dsn template called gregtest_dsn
[gregtest]
Driver = /usr/lib/odbc/libmyodbc.so
SERVER = localhost
PORT = 3306
DATABASE = gregtest
OPTION = 3
USER = majorpayne
PASSWORD = ******** < replace with password!
# install dsn
odbcinst -i -s -l -f gregtest_dsn
# query system dsn's
odbcinst -q -s
#connect
isql -v gregtest
# should connect and be able to run sql statements! :)
# Make more DSN's for other databases by adding more template files and repeating the steps above.
Edit 7/7/11:
I think pgsql odbc should not be /usr/lib/odbc/libodbcpsql.so , but rather /usr/lib/odbc/psqlodbca.so.
I have not tested, but I later realized libodbcpsql.so does not exist. Just an FYI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment