How to Install the MySQL ODBC Driver on Ubuntu 16.04?
# apt-get install libmyodbc Reading package lists... Done Building dependency tree Reading state information... Done Package libmyodbc is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'libmyodbc' has no installation candidatePrior to that MySQL could be accessed via ODBC-based applications, after having the ODBC driver installed using a simple Terminal command:
apt-get install libmyodbc
As for the latest version, all efforts to search the Ubuntu repository for the ODBC driver are in vain: of all the repositories listed in the software sources, none of them include the libmyodbc package. According to the Ubuntu version history, the package used to exist but has been deleted due to a certain bug.
MySQL 5.7, as opposed to other versions, restricts symbols available in libmysqlclient20. It looks like MyODBC uses some of these symbols, so it cannot be installed from libmysqlclient-dev.
In fact, maintaining MyODBC in Ubuntu is a disputable question, since there are no hard dependencies on it, and it is a default alternative for libreoffice-canzeley-client.
Thus, MyODBC that uses libmysqlclient functions incompatible with MySQL 5.7 is not supported by Ubuntu 16.04 at the moment. Once the work on MySQL 5.7 is finished, Ubuntu developers may get it back into the release. However, there is a chance it is never going to happen.
If you have software that absolutely requires the MySQL ODBC driver, it is possible to set one up and get it working on Ubuntu 16.04. To do it, take the following steps:
- Download the ODBC driver for Ubuntu 15.10 (mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit.tar.gz) from this page.
- Extract the files:
tar -xvf mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit.tar.gz
- Copy the driver to the ODBC folder:
sudo cp mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit/lib/libmyodbc5* /usr/lib/x86_64-linux-gnu/odbc/
- Install it:
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;"
- Create DSN:
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"
- Сonnect the database and query it:
radik@radik-VirtualBox:~$ isql test +—————————————+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +—————————————+ SQL> show tables +——————————————————————+ | Tables_in_mysql | +——————————————————————+ | columns_priv | | db | | engine_cost | | event | | func | ………. +——————————————————————+
- You’ll finally get the following file configuration:
radik@radik-VirtualBox:~$ cat /etc/odbc.ini [test] Driver=MySQL SERVER=127.0.0.1 UID=root PWD=123456 DATABASE=mysql PORT=3306 radik@radik-VirtualBox:~$ cat /etc/odbcinst.ini [MySQL] Driver=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5w.so UsageCount=1The ODBC driver for MySQL is installed. Your software now has an opportunity to establish connection with MySQL directly via TCP/IP.