PHP ODBC Connect Cloudera Impala and Hive


CentOS 5.5
PHP 5.3.10
(This article also works for PHP 5.3.3 on CentOS 6).



UnixODBC can be installed from yum repo

I built a unixODBC 2.3.2 from source, installed to /usr/local/unixODBC

ODBC Connectors

Cloudera offers ODBC libs for both Hive and Impala:

Follow the install guide on urls above, only wget and yum –nogpgcheck localinstall xxx.rpm required.

PHP Extensions

You can install PHP-ODBC or PHP-PDO-ODBC, either from source or yum repo.
If you meet some error building PHP-ODBC, this article might be useful: Build Old PHP-ODBC from Source

Configure Connectors

Connectors are installed under /opt/cloudera, both of them provide a folder named ‘Setup‘ with three files in it:

  • cloudera.impalaodbc.ini
  • odbc.ini
  • odbcinst.ini


I’m using the unixODBC built from source:

And comment all rest lines about ODBCInstLib.



nothing changed.



If you have your unixODBC installed from yum:

If built from source:


Guide says ini-s can be copied to ~ and prepend a ‘.‘ to make it ‘invisible‘.
But I prefer to set up ENV:

These can be set inside PHP script with putenv(),
I’ll paste test script later.


Test script using PHP-PDO-ODBC and PHP-ODBC are pasted below.
Remember to use DSN=MyImpala instead of shared object file path(from install guide), Driver=(from php doc), …

Trouble Shooting

Can’t open cursor lib

Error message may like


Solution is create a symbolic link:

Segmentation fault

If you meet these, go back and check your configurations and DSN syntax.

zend_mm_heap corrupted

This occurs when using php-odbc based on unixODBC 2.2.11 from yum on centos 5.5.
Build the latest unixODBC from

Useful links

PHP ODBC Connect Cloudera Impala and Hive by @sskaje:

Incoming search terms: