What Is It?

MySQL2ODBC is a library for intercepting MySQL API calls and redirecting them via ODBC.


Historically the open-source community has produced many useful applications tied to the LAMP stack (Linux, Apache, MySQL and PHP) or similar variants. Often, however, the reliance on MySQL as the database layer of choice has been baked-in with little scope for substituting another RDBMS.

On the other hand, ODBC has long provided flexible choice of backend RDBMS - by talking ODBC, an application can switch between PostgreSQL, MySQL, Oracle, SQL Server, OpenLink Virtuoso and many more at will.

MySQL2ODBC is one way to break free of vendor lock-in and restore database-independence via ODBC :)


  • Cost-Effectiveness - MySQL2ODBC saves having to rewrite the whole database access layer in a potentially large application
  • Database-Independence: Freedom of Choice


MySQL2ODBC provides a substitute libmysqlclient library.


Building MySQL2ODBC

  • Download mysql2odbc-0.99.2.tar.gz
  • unpack it somewhere in your usual source directory tar xvpfz mysql2odbc-0.99.2.tar.gz
  • check the options to configure by running ./configure --help - you can choose which ODBC Driver Manager to work with, either unixODBC or iODBC
  • ./configure --with-iodbc=/usr/local/iodbc --prefix=/usr/local/mysql2odbc
  • make
  • sudo make install

Deploying MySQL2ODBC

Your application needs to be told to use the MySQL2ODBC implementation of libmysqlclient in preference to the existing version. To do this, either

export LD_LIBRARY_PATH=/usr/local/mysql2odbc/lib


export LD_PRELOAD=/usr/local/mysql2odbc/lib/

and restart the application. You might want to create a shell-script wrapper to preserve this.

Download & License

The source can be downloaded from github as a zip archive: MySQL2ODBC source zip.

Alternatively you can clone the repository:

git clone

The project is licensed under the terms of the GNU Library General Public License (LGPL) v2.

Patches are welcomed - please either send us a merge request via github or email the OpenLink iODBC source archive manager at, including documentation. Thank you for your contributions :)