Install ODBC on Ubuntu 20.04, 20.10, and above

--

There used to easy apt install for ODBC like “apt-get install libmyodbc” , not anymore. You have to do some extra effort now

Follow these steps.

apt install unixodbcapt unixodbc-dev -y

cd ~

wget http://ftp.airnet.ne.jp/mirror/mysql/Downloads/Connector-ODBC/5.3/mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit.tar.gz

tar -xvf mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86–64bit.tar.gz

sudo cp mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86–64bit/lib/libmyodbc5* /usr/lib/x86_64-linux-gnu/odbc/

sudo mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86–64bit/bin/myodbc-installer -d -a -n “MySQL” -t “DRIVER=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5w.so;”

sudo mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86–64bit/bin/myodbc-installer -s -a -c2 -n “test” -t “DRIVER=MySQL;SERVER=127.0.0.1;DATABASE=mysql;UID=root;PWD=123456”

sudo mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86–64bit/bin/myodbc-installer -s -a -c2 -n “test” -t “DRIVER=MySQL;SERVER=127.0.0.1;DATABASE=mysql;UID=root;PWD=123456”

Following steps are for testing the connectivity

odbcinst -q -d

odbcinst -q -s

isql test — will also give you connected message, make sure that your have correct DB and table otherwise it will throw “[ISQL]ERROR: Could not SQLConnect”.

Create a test python script to test connectivity

apt install python3-pip

pip install — upgrade pyodbc

vim test.py

add following lines in test.py

— — — — — — — — — — — — — — — — —

# coding=UTF-8

import pyodbc

print(“connecting …”)

cnxn = pyodbc.connect(“DSN=test”)

cursor = cnxn.cursor()

rows = cursor.execute(“select * from TABLES”).fetchall()

cursor.close()

except Exception as e:

print(repr(e))

— — — — — — — — — — — — — -

chmod 777 test.py

python3 test.py

You will see it connected !!!

Following are the sample files, in case you need troubleshooting.

https://github.com/ERPGulf/docs/blob/main/odbc.ini

https://github.com/ERPGulf/docs/blob/main/odbcinst.ini

Originally published at https://erpgulf.com on January 29, 2021.

--

--

ERPGulf - - - Whatsapp: 00974-55124924
ERPGulf - - - Whatsapp: 00974-55124924

Written by ERPGulf - - - Whatsapp: 00974-55124924

Customized hosting of ERPNext for the Gulf countries. . Contact us on sales@ERPGulf.com Call 00974–55124924. Build your cloud server on www.Claudion.com

No responses yet