Installing Ubuntu 16.04 LTS: How to install ODBC?

53,626

Solution 1

Download directly from dev.mysql.com: https://dev.mysql.com/downloads/connector/odbc/

Select Ubuntu 16.04 64 bit or 32 bit (probably 64 bit), download the TAR ball, then copy the file libmyodbc5a.so to /usr/lib/x86_64-linux-gnu/odbc/

then, create /etc/odbcinst.ini

[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc5a.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1

and /etc/odbc.ini

[my-connector]
Description           = MySQL connection to  database
Driver                = MySQL
Database              = mydb
Server                = localhost
User             = dbuser
Password              = dbpass
Port                  = 3306
Socket                = /var/run/mysqld/mysqld.sock

Note that the username tag is User (and not username as seen in some examples) and the socket is under /var/run and not under /var/lib

echo "select 1" | isql -v my-connector

then worked for me

Solution 2

I found it in http://dev.mysql.com/downloads/connector/odbc/ (I selected "Ubuntu Linux 15.10 (x86, 64-bit), Compressed TAR Archive")

Dowload it and extract files, then you get libmyodbc5a.so (for ANSI system) and libmyodbc5w.so (for Unicode).

Solution 3

The package is available for Xenial and it can be seen here. Therefore, it should install. Make sure you run a sudo apt-get update before installing. Also, make sure that the universe repository for Xenial is part of your sources (as the above link shows, this package belongs to the universe repository). You can check this source is part of your available sources in the etc/apt/sources.list file. There should be a line such as:

deb http://com.archive.ubuntu.com/ubuntu/ xenial universe

(The mirror could be different from com.archive...)

If still you cannot install it (which is strange), then go to the above website, choose you architecture version and download the .deb file. For example, for amd64, the file is this one: http://launchpadlibrarian.net/141005765/libmyodbc_5.1.10-3_amd64.deb. Then, open a terminal, go to the folder containing the file and run:

sudo dpkg -i file.deb
sudo apt-get install -f

(The latter command is in case some dependencies are unmet)

Share:
53,626
Ernie
Author by

Ernie

Updated on September 18, 2022

Comments

  • Ernie
    Ernie almost 2 years

    After installing a fresh new copy of Ubuntu 16.04, I tried to install MySQL ODBC as per the official documentation at https://help.ubuntu.com/community/ODBC:

    # 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
    

    I can see this is getting off to a great start!

    Searching the package repository for ODBC hasn't been particularly helpful either. This is a very important part of any modern Linux system! Where did it go?!

    PS: Updating the documentation at help.ubuntu.com would be nice too!

    Edited to add: Also, it seems that the driver file libmyodbc.so doesn't exist on this version of Ubuntu.

    • Lord_PedantenStein
      Lord_PedantenStein almost 8 years
      try apt-cache search libmyodbc to list packages with a similar name. This is what the "reffered to by another package" ist about. Or check if it is listed in synaptic. Don't forget to apt-get update before installing/upgrading packages with apt.
    • Ernie
      Ernie almost 8 years
      I don't bother with apt-cache, I just search packages.ubuntu.com.
    • edwinksl
      edwinksl almost 8 years
      Either way, libmyodbc does not exist for 16.04.
    • Ernie
      Ernie almost 8 years
      Cool. How do I get ODBC working on 16.04? I have software that absolutely requires it.
  • edwinksl
    edwinksl almost 8 years
    The package used to exist, but it has been deleted from the universe repo as you can see from its publishing history at launchpad.net/ubuntu/+source/myodbc/5.1.10-3/+publishinghist‌​ory. The reason for its removal is given at bugs.launchpad.net/ubuntu/+source/myodbc/+bug/1564856. Enabling the universe repo wouldn't help. The package is "available" in a very particular sense of the word, which is that its .deb file prior to removal is available. One can install the .deb file with sudo dpkg -i, but the package hasn't been maintained for a while and is probably broken.
  • Marc Vanhoomissen
    Marc Vanhoomissen over 7 years
    Please note that the odbcinst.ini as proposed is for the ANSI version of the driver. If you need UNICODE characters, you are better off with the UNICODE version: libmyodbc5w.so (in the driver line)
  • e3oroush
    e3oroush about 7 years
    Thanks for your answer. It works like a charm in Ubuntu 16.04
  • JDS
    JDS almost 6 years
    Just in case anyone else hits the problem I hit: The "latest" as of 2018-09-01 was v8.12. I encountered a bug in the lastest in both of these, and tried to use the 5.X version. But the dev.mysql.com site only had 8.12 or 5.11 available. I scoured the internet for the 5.10 version which I was pretty sure would work, and found it on an FTP mirror. There are a number of those, mostly at universities. So, long story short: to downgrade your downgrade, try googling "mysql ftp mirror"
  • mike rodent
    mike rodent over 2 years
    As at 2022-03, make sure you choose "Linux - Generic" under "Select Operating System"... that is the only way to download the tarball file. Everything else is .deb (or the source code). libmyodbc5a.so has to be adjusted to the version MySQL number, 8 in my case, so libmyodbc8a.so.