SQL Server ODBC Driver for Linux/Unix Getting Started Tutorial

How to download and install the ODBC driver for SQL Server. How to access SQL Server 7.0, 2000, 2005, 2008, 2012, 2014 and Express databases from Linux and Unix.

MSSQL Driver for Linux/UNIX

When developing this tutorial, we used our SQL Server ODBC driver to access SQL Server from RedHat and Kubuntu/Ubuntu (Edgy Eft/Feisty Fawn/Gutsy Gibbon/Hardy Heron) platforms. MSSQL Linux The SQL Server ODBC driver should work on any recent 32-bit or 64-bit Linux distribution: CentOS, Debian GNU/Linux, Fedora (Core, Moonshine/Werewolf/Sulphur), Mandrake/Mandriva, OpenSUSE/SUSE, Oracle Enterprise Linux (OEL), RedHat Enterprise Linux (RHEL) and Slackware. MSSQL UNIX The SQL Server ODBC driver is also available for 32-bit and 64-bit AIX, HP-UX and Solaris platforms.

Download MSSQL driver for ODBC MSSQL connectivity:

Step 1: What You Need To Know

Before you begin, contact your database administrator for the following information:

Step 2: Download the SQL Server ODBC Driver Distribution

  1. Log in at http://www.easysoft.com.

    If you have not yet done so, you need to register first. On the registration form, an asterisk (*) indicates that a field is mandatory.

  2. Download the Easysoft ODBC-SQL Server Driver distribution for your Unix platform.

    The SQL Server ODBC driver is a single product that supports SQL Server 7—2014x and Express. By downloading one product distribution, you effectively get a SQL Server 7.0 ODBC driver, a SQL Server 2000 ODBC driver, a SQL Server 2005 ODBC driver, a SQL Server 2008 ODBC driver, a SQL Server 2012 ODBC driver, a SQL Server 2014 ODBC driver and a SQL Server Express ODBC driver for Linux/Unix.

  3. Save the distribution file to a temporary directory on the machine where you want to install the SQL Server ODBC driver.

Step 3: Install the SQL Server ODBC Driver

Note You need root access on the machine where you want to install the SQL Server ODBC driver.

  1. Log in to your Unix system and cd into the directory where you downloaded the SQL Server ODBC driver distribution. For example:
    cd /tmp
  2. Unpack the distribution file:
    tar -xvf odbc-sqlserver-version-platform.tar

    Replace version and platform with the version number and platform contained in the distribution file name. For example, to unpack the 32-bit Linux distribution:

    tar -xvf odbc-sqlserver-1.2.0-linux-x86-glibc.tar
  3. cd into the directory created by unpacking the distribution file. For example:
    cd odbc-sqlserver-1.2.0-linux-x86-glibc
  4. To start the installation, as root, type:
    ./install
  5. Accept the default choices throughout the installation by pressing RETURN. To accept the terms of the Easysoft End User License Agreement, type Yes. At certain points in the installation, the installation script pauses to report its progress. To continue to the next stage, press RETURN.
  6. When prompted to choose a product to license, choose the SQL Server ODBC driver by typing its option number:
    [0] Exit
    [1] View existing licenses
    [2] SQLServer ODBC Driver V1.2
    
    Please choose the product you would like a license for by entering its
    item number or enter one of the other options.
    
    Option: 2

    Next, you need to supply:

    1. Your full name
    2. Your company name
    3. An email contact address. This must be the email address you registered on the Easysoft web site.
    4. Your telephone number (you need to specify this if you telephone the license request to us).
    5. Your fax number (you need to specify this if you fax the license request to us).
    6. A reference number. When applying for a trial license just press ENTER. This field is used to enter a reference number we will supply you for full (paid) licenses.

    The License Client asks you to choose a method for obtaining the license. To obtain a license automatically, you need to be connected to the Internet and allow outgoing connections to license.easysoft.com on port 8884. If you are not connected to the Internet or do not allow outgoing connections through port 8884, the License Client can create a license request file which you can:

    1. Enter at http://www.easysoft.com/support/licensing/trial_license.html to obtain your license.
    2. Supply to Easysoft by mail, fax or telephone.

    If you choose option [2], the license request is written to a file named license_request.txt and you should exit the License Client (option [0]) and complete the installation. Once you have mailed, faxed or telephoned the license request to us, we will return a license key. Add this to the end of the file /usr/local/easysoft/license/licenses.

  7. The installation searches for SQL Server instances that are listening on your network and displays the instances it finds. For example:
    ==================================================================
    
    ServerName MYSQLSERVER2000HOST Port 1433 (Default)
    
    ServerName MYSQLEXPRESSHOST\SQLEXPRESS Port 2777
    
    ServerName MYSQLSERVER2005HOST\MYINSTANCEI Port 1510
    
    ServerName MYSQLSERVER2005HOST\MYINSTANCEII Port 1511
    
    ==================================================================

    The example output shows that:

    • The default SQL Server instance on a machine named MYSQLSERVER2000HOST is listening on the default SQL Server TCP port 1433.
    • The default named SQL Server Express instance on a machine named MYSQLEXPRESSHOST is listening on port 2777.
    • There are two named instances running on MYSQLSERVER2005HOST. The instances are listening on ports 1510 and 1511 respectively.

    Do one of the following:

    • If your SQL Server instance is displayed in the list, type y.
    • If your SQL Server instance is not listed, type n. The SQL Server instance may not be running or the SQL Server Browser or listener service that the installation uses to find SQL Server instances may not be running.

      Check with your database administrator that the SQL Server instance is running, and then skip to Step 4: Access an SQL Server ODBC Driver Data Source.

  8. Type the host name (or IP address) of the machine where your SQL Server instance is running when prompted. To connect to a named instance, use the format machinename\instancename. To connect to a SQL Server Express instance, use the format machinename\SQLEXPRESS. To connect to a SQL Server instance that is not listening on the default port (1433), use the format machinename:port.

    Based on the example output shown earlier, you would type:

    • MYSQLSERVERHOST to connect to the default instance on this machine.
    • MYSQLEXPRESSHOST\SQLEXPRESS to connect to the SQL Server Express instance.
    • MYSQLSERVER2005HOST:1510 to connect to the first named instance on this machine and MYSQLSERVER2005HOST:1511 to connect to the second.
  9. Type your SQL Server login name when prompted. If you usually connect to SQL Server through your Windows account, type your Windows user name. If the SQL Server instance is running on a machine that is part of a Windows domain, use the format domain\username.

    Otherwise, type a valid SQL Server user name.

  10. Type the password for your user name when prompted.

    If the installation can successfully connect to the SQL Server instance, a list of databases that you can access is displayed.

  11. Press RETURN to accept the default database for your SQL Server login.
  12. Press RETURN to accept the default language for SQL Server system messages.

    The SQL Server ODBC driver installation has now gathered enough information to connect to SQL Server.

  13. Type y when prompted whether to save the connection information in an ODBC data source and then type a DSN name. For example, mssql-linux-odbc-dsn. You can use this data source to connect to SQL Server now and when the installation completes. The data source is written to /etc/odbc.ini.
  14. Type y when prompted whether to retrieve a list of tables from the SQL Server databases.

    The installation uses unixODBC’s isql program and your new data source to retrieve the data.

    Note If you chose not to license the SQL Server ODBC driver earlier in the installation, skip this step. The ODBC-SQL Server Driver needs to be licensed before it can be used to connect to a data source. When the installation has finished, you can use isql to test the data source after you have licensed the ODBC-SQL Server Driver.

    At the end of the installation, you will have installed and licensed the SQL Server ODBC driver, installed the unixODBC Driver Manager and created an ODBC data source.

  15. Set and export the LD_LIBRARY_PATH environment variable:
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/easysoft/sqlserver:/usr/local/easysoft/lib
    export LD_LIBRARY_PATH

    Note On AIX, replace LD_LIBRARY_PATH with LIBPATH.

Step 4: Access an SQL Server ODBC Driver Data Source

  1. Do one of the following:
    • If you interactively created a data source during the SQL Server ODBC driver installation, skip to step 5.
    • If you did not create an data source during the installation, you need to create one. The SQL Server ODBC driver installation creates a sample data source named SQLSERVER_SAMPLE that you can use as a starting point.
  2. As root, open /etc/odbc.ini in a text editor.
  3. To locate the sample data source, search for [SQLSERVER_SAMPLE].
  4. Change these attribute values:
    AttributeValue
    ServerThe host name (or IP address) of the machine where your SQL Server instance is running. To connect to a named instance, use the format machinename\instancename. To connect to a SQL Server Express instance, use the format machinename\SQLEXPRESS.
    PortIf the SQL Server instance is listening on the default port, leave this set to 1433. If your database administrator told you to specify a different port, replace 1433 with the new port number. Otherwise, delete 1433.
    DatabaseDelete the sample entry Northwind to connect to the default database defined for your login.
    UserYour SQL Server login name. If you usually connect to SQL Server through your Windows account, type your Windows user name. If the SQL Server instance is running on a machine that is part of a Windows domain, use the format domain\username. Otherwise, type a valid SQL Server user name.
    PasswordThe password for the login name specified by User.

    Examples

    This data source uses a Windows user name and password to connect to the default SQL Server instance on a machine named MYSQLSERVER2000HOST.

    [SQLSERVER_SAMPLE]
    Driver		= Easysoft ODBC-SQL Server
    Description	= Easysoft SQL Server ODBC driver
    Server		= MYSQLSERVER2000HOST
    Port		= 1433
    Database	= 
    User		= mydomain\mywindowsuser
    Password	= mywindowspassword

    This data source uses a SQL Server user name and password to connect to a SQL Server Express instance. The SQL Server port is omitted and the SQL Server ODBC driver will therefore use the SQL Server Browser to detect the port.

    [SQLSERVER_SAMPLE]
    Driver		= Easysoft ODBC-SQL Server
    Description	= Easysoft SQL Server ODBC driver
    Server		= MYSQLEXPRESSHOST\SQLEXPRESS
    Port		= 
    Database	= 
    User		= mysqlserverusername
    Password	= mysqlserverpassword

    (The SQL Server ODBC driver is a single product that supports SQL Server 7—2014 and Express. By downloading one product distribution, you effectively get a SQL Server 7.0 driver, a SQL Server 2000 driver, a SQL Server 2005 driver, a SQL Server 2008 driver, a SQL Server 2012 ODBC driver, a SQL Server 2014 ODBC driver and a SQL Server Express driver for Linux/Unix.)

  5. Use isql to test the new data source:
    cd /usr/local/easysoft/unixODBC/bin
    ./isql -v dsn_name

    where dsn_name is name of your ODBC data source. If you created a data source during the SQL Server ODBC driver installation, specify that data source name. If you have just edited the sample SQL Server ODBC driver data source, type SQLSERVER_SAMPLE.

    If you are unable to connect, see the Easysoft ODBC-SQL Server Driver Knowledge Base for help on solving some common connection problems.

  6. At the prompt, type a select statement or type help to display a list of tables. To exit, press RETURN in an empty prompt line.

What Next?

You are now ready to use the SQL Server ODBC driver with your own applications and development tools on your UNIX/Linux SQL Server client machine.

Further Support

Getting Started Feedback

* Did this content help you?
* Please select one option based on your first choice:

(* Required Fields)