Partager via


Install SQL ODBC driver on SUSE Linux

We have Few very good documents available for installing SQL ODBC on RedHat linux but when it comes to SUSE linux we don't have one document which can help us end to end.

As we need to make sure we install right version of msodbcsql and also unixODBC

 

So lets start with what we have to do....

 

Steps to Install SQL ODBC driver on SuseLinux

We have followed following two articles (ans of course some common sense!!!):
https://technet.microsoft.com/en-us/library/hh568449%28v=sql.110%29.aspx
https://onefinepub.com/2013/03/ms-sql-odbc-ubuntu/

Pre requisite so that we have wget, make and gcc commands available

 
 sudo zypper addrepo https://download.opensuse.org/repositories/network:/utilities/openSUSE_12.1/ opensuse-network-utilities-x86_64
 sudo zypper install wget
 sudo zypper install make
 sudo zypper install gcc
 

1) Install msodbcsql archive for suse

 wget https://download.microsoft.com/download/7/3/1/7318E2AD-E7C5-4301-AEFA-A15EDEDACFB4/msodbcsql-11.0.2260.0.tar.gz

2) unzip archive and put it in folder

 tar -zxvf msodbcsql-11.0.2260.0.tar.gz

3)chnage directory to msodbcsql-11.0.2260.0

 cd msodbcsql-11.0.2260.0

4) Install UnixODBC driver which is required for any ODBC connetcion to work

 wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.0.tar.gz

5) Unzip unix odbc to install it

 tar -zxvf unixODBC-2.3.0.tar.gz

6)Now we have to install unixODBC driver and make sure it is installed correctly

 ./build_dm.sh --download-url=file://unixODBC-2.3.0.tar.gz.

It will ask whether you want to install script or not, say YES
After this it will go ahead and install unixODBC on your machine.

5) At the end it will tell to change directory to some temp path and run "make install" command
just copy pase those commands and it will do the trick.
Command for my machine was(most probably it will same for everyone, run each commadn separately):  'cd /tmp/unixODBC.8503.14603.23788/unixODBC-2.3.0; make install'

6) After this make sure you get back to your home directory
For my environment it needed following commands

 cd..
 cd..
 cd..
 cd home/<user name>/
 cd msodbcsql-11.0.2260.0/

6)Now we have to install SQLODBC (make sure we are in directory msodbcsql-11.0.2260.0)
    -> make sure we are in directory msodbcsql-11.0.2260.0

    -> First we have to Run install script
        

 sudo bash install.sh install --accept-license --force

        
    -> make sure the SQL Server dependencies are installed:
        

 sudo zypper install openssl libkrb5-3 libc6 e2fsprogs

    --> run sqlcmd -?
        if it gives error "sqlcmd: error while loading shared libraries: libcrypto.so.0.9.8: cannot open shared object file: No such file or directory"
        run below command
        

 sudo zypper install libopenssl0_9_8

    
    --> run sqlcmd -?
        and it rill show below output
        

  Microsoft (R) SQL Server Command Line Tool
 Version 11.0.2260.0 Linux
 Copyright (c) 2012 Microsoft. All rights reserved.
 
 usage: sqlcmd [-U login id] [-P password]
 [-S server or Dsn if -D is provided]
 [-H hostname] [-E trusted connection]
 [-N Encrypt Connection][-C Trust Server Certificate]
 [-d use database name] [-l login timeout] [-t query timeout]
 [-h headers] [-s colseparator] [-w screen width]
 [-a packetsize] [-e echo input] [-I Enable Quoted Identifiers]
 [-c cmdend]
 [-q "cmdline query"] [-Q "cmdline query" and exit]
 [-m errorlevel] [-V severitylevel] [-W remove trailing spaces]
 [-u unicode output] [-r[0|1] msgs to stderr]
 [-i inputfile] [-o outputfile]
 [-k[1|2] remove[replace] control characters]
 [-y variable length type display width]
 [-Y fixed length type display width]
 [-p[1] print statistics[colon format]]
 [-R use client regional setting]
 [-b On error batch abort]
 [-D Dsn flag, indicate -S is Dsn]
 [-X[1] disable commands, startup script, environment variables [and exit]]
 [-x disable variable substitution]
 [-? show syntax summary]

    So now sqlcmd is ready for use.
        
    -> if it gives error regarding linking for crpto libraries (not needed if we have followed previous step correctly)
        Create some symlinks so everything works with the paths these binaries are expecting to find libraries: \        

  sudo ln -s /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/x86_64-linux-gnu/libcrypto.so.10;
 sudo ln -s /lib/x86_64-linux-gnu/libssl.so.1.0.0 /usr/lib/x86_64-linux-gnu/libssl.so.10;
 sudo ln -s /usr/lib/x86_64-linux-gnu/libodbcinst.so.2.0.0 /usr/lib/x86_64-linux-gnu/libodbcinst.so.1;
 sudo ln -s /usr/lib/x86_64-linux-gnu/libodbc.so.2.0.0 /usr/lib/x86_64-linux-gnu/libodbc.so.1

I will finish this article here. 

If you have any questions feel free to add in comments section.

Comments

  • Anonymous
    February 16, 2015
    Thank you for this post, it helped me. ;)

  • Anonymous
    February 16, 2015
    Hi Aleph0, Good to know that I could help. Have fun... :) Thanks, Dilkush

  • Anonymous
    October 09, 2015
    This was very complete and accurate. Thank you for writing up a helpful doc!

  • Anonymous
    October 09, 2015
    Finally someone used this blog!!!! All hard work paid off.... Kidding.... good to hear this helped.... -Dilkush

  • Anonymous
    February 22, 2016
    Thanks for the post. This was helpful - esp since more recent versions of the unixodbc are not working as expected (ex - 2.3.1 or 2.3.4).