DataSunrise is sponsoring AWS re:Invent 2024 in Las Vegas, please visit us in DataSunrise's booth #2158

How to Install the MySQL ODBC Driver on Ubuntu 16.04?

How to Install the MySQL ODBC Driver on Ubuntu 16.04?

The seemingly easy task to install the MySQL ODBC driver on Ubuntu 16.04 has turned out to be a challenge. It has resulted from the driver upgrade problem that Ubuntu developers couldn’t have handled.

If you have the latest version of Ubuntu 16.04 installed on your system, you may have already hit a snag while attempting to locate the ODBC driver.

# 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 candidate

Prior 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:

  1. Download the ODBC driver for Ubuntu 15.10 (mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit.tar.gz) from this page.
  2. Extract the files: tar -xvf mysql-connector-odbc-5.3.6-linux-ubuntu15.10-x86-64bit.tar.gz
  3. 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/
  4. 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;"

Check its functioning:

  1. 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"
  2. С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 |
    ……….
    +——————————————————————+
    
  3. 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=1
    

The ODBC driver for MySQL is installed. Your software now has an opportunity to establish connection with MySQL directly via TCP/IP.

Does your MySQL or other database contain sensitive information that requires robust protection? Are you seeking compliance with regulations like GDPR, SOX, or HIPAA? Discover how DataSunrise’s data security, audit, and data masking software can help. Experience our data protection firsthand: Schedule an online demo or start your free trial today. Discover how we secure your critical information.

Next

Getting SSL Certificate with “Let’s Encrypt”

Getting SSL Certificate with “Let’s Encrypt”

Learn More

Need Our Support Team Help?

Our experts will be glad to answer your questions.

General information:
[email protected]
Customer Service and Technical Support:
support.datasunrise.com
Partnership and Alliance Inquiries:
[email protected]