How to connect to Cloudera Impala using PHP ODBC

This article explains the configurations required to connect to Cloudera Impala using PHP ODBC.

Step1: Login to the server as root via ssh.

Step2: load the Impala ODBC drivers from "".

We can select the package according to the OS distribution of the server.

Step3: Install the downloaded package.

For RHEL/Centos Systems,

#rpm -ivh clouderaimpala_*.rpm

For Debian/Ubuntu Systems,

#dpkg -i clouderaimpala_*.deb

Step4: Install the unixODBC package.

For RHEL/Centos Systems,

#yum install unixODBC

For Debian/Ubuntu Systems,

#apt install unixodbc 

Step5: Open the impala-odbc configuration file.

#vi /opt/cloudera/impalaodbc/lib/64/cloudera.impalaodbc.ini

Step6: Comment out the following line.

Step7: Add the following line and save the file.

Step8: Open the odbc configuration file.

#vi /opt/cloudera/impalaodbc/Setup/odbc.ini

Step9: Update the values of the following variables and save the file.


Step10: Install the php-odbc module.

For RHEL/Centos Systems,

#yum install php-odbc

For Debian/Ubuntu Systems,

#apt-get install php-odbc

Step11: Restart Apache service.

For RHEL/Centos Systems,

#systemctl restart httpd

For Debian/Ubuntu Systems,

#systemctl restart apache2

Step12: Save the following PHP code to a file and execute the same to verify the connection to impala.



function commands($query){
    $connection= odbc_connect("DSN=NAME;", '', '');
    $rs=odbc_exec($connection, $query);
    return $rs;

print_r(commands("SHOW DATABASES"));


Where NAME need to be replaced with the DSN tag under which we have configured the impala host details in in "/opt/cloudera/impalaodbc/Setup/odbc.ini".

That's all…