Microsoft Sql Server 2008 Odbc Drivers For Mac

-->
  1. The Microsoft JDBC Driver for SQL Server is a Type 4 JDBC driver that provides database connectivity through the standard JDBC application program interfaces (APIs) available in the Java Platform, Enterprise Editions.
  2. The Actual SQL Server ODBC Driver lets you access your company's Microsoft SQL Server and Sybase databases from within Microsoft Excel and FileMaker Pro.

This article explains how to install the Microsoft ODBC Driver for SQL Server on Linux and macOS, as well as the optional Command-Line Tools for SQL Server (bcp and sqlcmd) and the unixODBC Development Headers.

Microsoft ODBC Driver 17 for SQL Server

ODBC is the primary native data access API for applications written in C and C++ for SQL Server. There is an ODBC driver for most data sources. Other languages that can use ODBC include COBOL, Perl, PHP, and Python.

Important

If you installed the v17 msodbcsql package that was briefly available, you should remove it before installing the msodbcsql17 package. This will avoid conflicts. The msodbcsql17 package can be installed side by side with the msodbcsql v13 package.

Debian

RedHat Enterprise Server

SUSE Linux Enterprise Server

Ubuntu

Note

  • Driver version 17.2 or higher is required for Ubuntu 18.04 support.
  • Driver version 17.3 or higher is required for Ubuntu 18.10 support.

MacOS

Microsoft ODBC Driver 13.1 for SQL Server

Debian 8

RedHat Enterprise Server 6

RedHat Enterprise Server 7

SUSE Linux Enterprise Server 11

SUSE Linux Enterprise Server 12

Ubuntu 15.10

Ubuntu 16.04

Ubuntu 16.10

OS X 10.11 (El Capitan) and macOS 10.12 (Sierra)

Microsoft ODBC Driver 13 for SQL Server

RedHat Enterprise Server 6

RedHat Enterprise Server 7

Ubuntu 15.10

Ubuntu 16.04

SUSE Linux Enterprise Server 12

Offline installation

If you prefer/require the Microsoft ODBC Driver 13 to be installed on a computer with no internet connection, you will need to resolve package dependencies manually. The Microsoft ODBC Driver 13 has the following direct dependencies:

  • Ubuntu: libc6 (>= 2.21), libstdc++6 (>= 4.9), libkrb5-3, libcurl3, openssl, debconf (>= 0.5), unixodbc (>= 2.3.1-1)
  • Red Hat: glibc, e2fsprogs, krb5-libs, openssl, unixODBC
  • SuSE: glibc, libuuid1, krb5, openssl, unixODBC

Each of these packages in turn has their own dependencies, which may or may not be present on the system. For a general solution to this issue, refer to your distribution's package manager documentation: Redhat, Ubuntu, and SUSE

It is also common to manually download all the dependent packages and place them together on the installation computer, then manually install each package in turn, finishing with the Microsoft ODBC Driver 13 package.

Redhat Linux Enterprise Server 7

  • Download the latest msodbcsql.rpm from here: https://packages.microsoft.com/rhel/7/prod/
  • Install dependencies and the driver

Ubuntu 16.04

  • Download the latest msodbcsql.deb from here: https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/msodbcsql/
  • Install dependencies and the driver

SUSE Linux Enterprise Server 12

  • Download the latest msodbcsql.rpm from here: https://packages.microsoft.com/sles/12/prod/
  • Install the dependencies and the driver
Install microsoft odbc driver for sql server

Once you have completed the package installation, you can verify that the Microsoft ODBC Driver 13 can find all its dependencies by running ldd and inspecting its output for missing libraries:

Microsoft ODBC Driver 11 for SQL Server on Linux

Before you can use the driver, install the unixODBC driver manager. For more information, see Installing the Driver Manager.

Installation Steps

Important

These instructions refer to msodbcsql-11.0.2270.0.tar.gz, which is installation file for Red Hat Linux. If you are installing the Preview for SUSE Linux, the file name is msodbcsql-11.0.2260.0.tar.gz.

To install the driver:

  1. Make sure that you have root permission.

  2. Change to the directory where the download placed the file msodbcsql-11.0.2270.0.tar.gz. Make sure that you have the *.tar.gz file that matches your version of Linux. To extract the files, execute the following command, tar xvzf msodbcsql-11.0.2270.0.tar.gz.

  3. Change to the msodbcsql-11.0.2270.0 directory and there you should see a file called install.sh.

  4. To see a list of the available installation options, execute the following command: ./install.sh.

  5. Make a backup of odbcinst.ini. The driver installation updates odbcinst.ini. odbcinst.ini contains the list of drivers that are registered with the unixODBC Driver Manager. To discover the location of odbcinst.ini on your computer, execute the following command: odbc_config --odbcinstini.

  6. Before you install the driver, execute the following command: ./install.sh verify. The output of ./install.sh verify reports if your computer has the required software to support the ODBC driver on Linux.

  7. When you are ready to install the ODBC driver on Linux, execute the command: ./install.sh install. If you need to specify an install command (bin-dir or lib-dir), specify the command after the install option.

  8. After reviewing the license agreement, type YES to continue with the installation.

Installation puts the driver in /opt/microsoft/msodbcsql/11.0.2270.0. The driver and its support files must be in /opt/microsoft/msodbcsql/11.0.2270.0.

Odbc Driver Sql Server 2014

To verify that the Microsoft ODBC driver on Linux was registered successfully, execute the following command: odbcinst -q -d -n 'ODBC Driver 11 for SQL Server'.

Use Existing MSDN C++ ODBC Samples for the ODBC Driver on Linux shows a code sample that connects to SQL Server using the ODBC driver on Linux.

Uninstalling

You can uninstall the ODBC driver 11 on Linux by executing the following commands:

  1. rm -f /usr/bin/sqlcmd

  2. rm -f /usr/bin/bcp

  3. rm -rf /opt/microsoft/msodbcsql

  4. odbcinst -u -d -n 'ODBC Driver 11 for SQL Server'

Troubleshooting Connection Problems

If you are unable to make a connection to SQL Server using the ODBC driver, use the following information to identify the problem.

The most common connection problem is to have two copies of the UnixODBC Driver Manager installed. Search /usr for libodbc*.so*. If you see more than one version of the file, you (possibly) have more than one driver manager installed. Your application might use the wrong version.

Enable the connection log by editing your /etc/odbcinst.ini file to contain the following section with these items:

Microsoft Sql Server 2008 Odbc Drivers For Mac

If you get another connection failure and do not see a log file, there (possibly) are two copies of the driver manager on your computer. Otherwise, the log output should be similar to the following:

If the ASCII character encoding is not UTF-8, for example:

There is more than one Driver Manager installed and your application is using the wrong one, or the Driver Manager was not built correctly.

For more information about resolving connection failures, see:

  • The error number specified in the URL (11001) should be changed to match the error that you see.

Driver Files

The ODBC Driver on Linux and MacOS consists of the following components:

Linux

ComponentDescription
libmsodbcsql-17.X.so.X.X or libmsodbcsql-13.X.so.X.XThe shared object (so) dynamic library file that contains all of the driver's functionality. This file is installed in /opt/microsoft/msodbcsql17/lib64/ for the Driver 17 and in /opt/microsoft/msodbcsql/lib64/ for Driver 13.
msodbcsqlr17.rll or msodbcsqlr13.rllThe accompanying resource file for the driver library. This file is installed in [driver .so directory]../share/resources/en_US/
msodbcsql.hThe header file that contains all of the new definitions needed to use the driver.
Note: You cannot reference msodbcsql.h and odbcss.h in the same program.
msodbcsql.h is installed in /opt/microsoft/msodbcsql17/include/ for Driver 17 and in /opt/microsoft/msodbcsql/include/ for Driver 13.
LICENSE.txtThe text file that contains the terms of the End-User License Agreement. This file is placed in /usr/share/doc/msodbcsql17/ for Driver 17 and in /usr/share/doc/msodbcsql/ for Driver 13.
RELEASE_NOTESThe text file that contains release notes. This file is placed in /usr/share/doc/msodbcsql17/ for Driver 17 and in /usr/share/doc/msodbcsql/ for Driver 13.

MacOS

ComponentDescription
libmsodbcsql.17.dylib or libmsodbcsql.13.dylibThe dynamic library (dylib) file that contains all of the driver's functionality. This file is installed in /usr/local/lib/.
msodbcsqlr17.rll or msodbcsqlr13.rllThe accompanying resource file for the driver library. This file is installed in [driver .dylib directory]../share/msodbcsql17/resources/en_US/ for Driver 17 and in [driver .dylib directory]../share/msodbcsql/resources/en_US/ for Driver 13.
msodbcsql.hThe header file that contains all of the new definitions needed to use the driver.
Note: You cannot reference msodbcsql.h and odbcss.h in the same program.
msodbcsql.h is installed in /usr/local/include/msodbcsql17/ for Driver 17 and in /usr/local/include/msodbcsql/ for Driver 13.
LICENSE.txtThe text file that contains the terms of the End-User License Agreement. This file is placed in /usr/local/share/doc/msodbcsql17/ for Driver 17 and in /usr/local/share/doc/msodbcsql/ for Driver 13.
RELEASE_NOTESThe text file that contains release notes. This file is placed in /usr/local/share/doc/msodbcsql17/ for Driver 17 and in /usr/local/share/doc/msodbcsql/ for Driver 13.

Resource File Loading

The driver needs to load the resource file in order to function. This file is called msodbcsqlr17.rll or msodbcsqlr13.rll depending on the driver version. The location of the .rll file is relative to the location of the driver itself (so or dylib), as noted in the table above. As of version 17.1 the driver will also attempt to load the .rll from the default directory if loading from the relative path fails. The default resource file paths are:

Linux: /opt/microsoft/msodbcsql17/share/resources/en_US/

MacOS: /usr/local/share/msodbcsql17/resources/en_US/

See Also

Active11 months ago

If you search Google for this question, you will find a lot of incorrect, misleading, and outdated information. Surprisingly, there isn't a solid answer on Stack Overflow, so we should change that.

I am using the Mac port installation of Apache and PHP. I have installed php5-mssql, and I can see mssql on my phpinfo() page.

But I don't see it listed under PDO.

Is mssql not associated with PDO? Is there another driver that can be used on a Mac to connect to a SqlServer database using PDO? Seems like this is something that should be possible.

Eric Z BeardEric Z Beard
28.2k24 gold badges92 silver badges142 bronze badges

5 Answers

Does this help you?

I use FreeTDS to connect to Microsoft SQL servers from a Linux server and it looks like the person in the link above has used FreeTDS to connect from a Mac.

Here is my /etc/freetds/freetds.conf file (the only part I added was at the very end for the XYZ server):

[Edit by the asker]

FreeTDS configuration is the first half of the answer. Once it's configured you should be able to run something like this from the command line and connect:

Then you need to use dblib, not mssql, as the PDO driver:

Where $dbhost is the name from the freetds.conf file

Eric Z Beard
28.2k24 gold badges92 silver badges142 bronze badges
Benny HillBenny Hill
5,5954 gold badges33 silver badges54 bronze badges

After looking at many threads, I've found that the best way to connect to MSSQL from Mac OS X with PHP 7 or older is to use dblib. (Just download the correct php version)

You can follow these instructions (ignoring the mssql.so extension) to connect very easily:

It worked perfect with OS X El Capitan, Bitnami with PHP 7.

Steps1.- Install XCode

2.- Install Homebrew

3.- Install autoconf using Homebrew.

4.- Install FreeTDS

5.- Download your version of PHP Source and uncompress it.

6.- Build the PDO DBLIB extension (Example for PHP 5.5.14)

7.- Add the .so extensio to php.iniextension=pdo_dblib.so

8.- Restart Apache

9.- Connect using the dblib dsn:

Esteban Eid JordánEsteban Eid Jordán

dblib is the driver that need to be used with mssql on unix systems

No need for you to install anything else,

E_pE_p

Thanks Esteban for the nice guide (https://stackoverflow.com/a/37707426) which succesfully helped me install the pdo_dblib driver.

However, I was having issues connecting to my Azure SQL database from OSX 10 with PHP (5.5) and FreeTDS using the provided dblib dsn. What finally fixed it for me was appending the Azure database (m53man42a) to my username.

My dblib PDO connection in PHP:

My FreeTDS.conf:

Consider adding this as a bullet number 10 in your list... :D

Community
holm50holm50

Microsoft Sql Server Odbc Download

Note that Microsoft have published a PHP7 extension for this, but if you're still on PHP5.x, that doesn't help you. I've succeeded in connecting using a different stack: freetds,odbc,pdo.

I'm using OS X 10.11.6 (El Capitan) with Macports, PHP5.6.

I've started by creating an Azure SQL Database called mydb on a server with a name of myserver.database.windows.net. It's important to remember to open the firewall to your client IP address, which you do on the server.

First step is to install freetds with the ODBC driver, and its PHP connector (change php56 to the correct version of your PHP):

Next, you need to include some lines in your configuration files:

/opt/local/etc/odbcinst.ini

This tells the odbc library where to find its odbc driver.

/opt/local/etc/freetds/freetds.conf

This tells the freetdc library where to find your server.

/opt/local/etc/odbc.ini

This creates a data source called myds pointing at your database, enabling you to connect with the following PHP:

If any of this doesn't work for you, first check that the freetds installation is correct using:

Sql Server 2008 Odbc Drivers

And then check that the ODBC specifications are OK using:

Thanks to https://github.com/lionheart/django-pyodbc/wiki/Mac-setup-to-connect-to-a-MS-SQL-Server, which does the equivalent job for Python and which pointed me in the right direction for all this.

Sql Server Odbc Driver Versions

xgretschxgretsch

Odbc Driver 11 For Sql Server

Not the answer you're looking for? Browse other questions tagged phpsql-serverpdo or ask your own question.

Comments are closed.