- Install the Microsoft ODBC driver for SQL Server (Linux)
- Microsoft ODBC 17
- Alpine Linux
- Debian
- Red Hat Enterprise Server and Oracle Linux
- SUSE Linux Enterprise Server
- Ubuntu
- Previous versions
- ODBC 13.1
- Debian 8
- Red Hat Enterprise Server 6
- Red Hat Enterprise Server 7
- SUSE Linux Enterprise Server 11
- SUSE Linux Enterprise Server 12
- Ubuntu 15.10
- Ubuntu 16.04
- Ubuntu 16.10
- ODBC 13
- Red Hat Enterprise Server 6 (ODBC 13)
- Red Hat Enterprise Server 7 (ODBC 13)
- Ubuntu 15.10 (ODBC 13)
- Ubuntu 16.04 (ODBC 13)
- SUSE Linux Enterprise Server 12 (ODBC 13)
- Offline installation
- Red Hat Linux Enterprise Server 7
- Ubuntu 16.04 (ODBC 13 offline)
- SUSE Linux Enterprise Server 12 (ODBC 13 offline)
- ODBC 11
- Installation Steps
- Uninstall
- Driver files
- Resource file loading
- Troubleshooting
- Next steps
- Установка Microsoft ODBC Driver for SQL Server (Linux)
- Microsoft ODBC 17
- Alpine Linux
- Debian
- Red Hat Enterprise Server и Oracle Linux
- SUSE Linux Enterprise Server
- Ubuntu
- Предыдущие версии
- ODBC 13.1
- Debian 8
- Red Hat Enterprise Server 6
- Red Hat Enterprise Server 7
- SUSE Linux Enterprise Server 11
- SUSE Linux Enterprise Server 12
- Ubuntu 15.10
- Ubuntu 16.04
- Ubuntu 16.10
- ODBC 13
- Red Hat Enterprise Server 6 (ODBC 13)
- Red Hat Enterprise Server 7 (ODBC 13)
- Ubuntu 15.10 (ODBC 13)
- Ubuntu 16.04 (ODBC 13)
- SUSE Linux Enterprise Server 12 (ODBC 13)
- Автономная установка
- Red Hat Linux Enterprise Server 7
- Ubuntu 16.04 (ODBC 13 в автономном режиме)
- SUSE Linux Enterprise Server 12 (ODBC 13 в автономном режиме)
- ODBC 11
- Процесс установки
- Удаление
- Файлы драйвера
- Загрузка файла ресурсов
- Устранение неполадок
- Дальнейшие действия
Install the Microsoft ODBC driver for SQL Server (Linux)
This article explains how to install the Microsoft ODBC Driver for SQL Server on Linux. It also includes instructions for the optional command-line tools for SQL Server ( bcp and sqlcmd ) and the unixODBC development headers.
This article provides commands for installing the ODBC driver from the bash shell. If you want to download the packages directly, see Download ODBC Driver for SQL Server.
Microsoft ODBC 17
The following sections explain how to install the Microsoft ODBC driver 17 from the bash shell for different Linux distributions.
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.
Alpine Linux
Driver version 17.5 or higher is required for Alpine support.
Debian
You can substitute setting the environment variable ‘ACCEPT_EULA’ with setting the debconf variable ‘msodbcsql/ACCEPT_EULA’ instead: echo msodbcsql17 msodbcsql/ACCEPT_EULA boolean true | sudo debconf-set-selections
Red Hat Enterprise Server and Oracle Linux
SUSE Linux Enterprise Server
Ubuntu
You can substitute setting the environment variable ‘ACCEPT_EULA’ with setting the debconf variable ‘msodbcsql/ACCEPT_EULA’ instead: echo msodbcsql17 msodbcsql/ACCEPT_EULA boolean true | sudo debconf-set-selections
Previous versions
The following sections provide instructions for installing previous versions of the Microsoft ODBC driver on Linux. The following driver versions are covered:
ODBC 13.1
The following sections explain how to install the Microsoft ODBC driver 13.1 from the bash shell for different Linux distributions.
Debian 8
Red Hat Enterprise Server 6
Red Hat Enterprise Server 7
SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 12
Ubuntu 15.10
Ubuntu 16.04
Ubuntu 16.10
ODBC 13
The following sections explain how to install the Microsoft ODBC driver 13 from the bash shell for different Linux distributions.
Red Hat Enterprise Server 6 (ODBC 13)
Red Hat Enterprise Server 7 (ODBC 13)
Ubuntu 15.10 (ODBC 13)
Ubuntu 16.04 (ODBC 13)
SUSE Linux Enterprise Server 12 (ODBC 13)
Offline installation
If you prefer/require the Microsoft ODBC Driver 13 to be installed on a computer with no internet connection, you’ll 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: Red Hat, Ubuntu, and SUSE
It’s 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.
Red Hat Linux Enterprise Server 7
- Download the latest msodbcsql .rpm from https://packages.microsoft.com/rhel/7/prod/.
- Install dependencies and the driver.
Ubuntu 16.04 (ODBC 13 offline)
- Download the latest msodbcsql .deb from https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/msodbcsql/.
- Install dependencies and the driver.
SUSE Linux Enterprise Server 12 (ODBC 13 offline)
- Download the latest msodbcsql .rpm from https://packages.microsoft.com/sles/12/prod/.
- Install the dependencies and the driver.
After you’ve 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:
ODBC 11
The following sections explain how to install the Microsoft ODBC driver 11 on Linux. Before you can use the driver, install the unixODBC driver manager. For more information, see Installing the Driver Manager.
Installation Steps
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:
Make sure that you have root permission.
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 .
Change to the msodbcsql-11.0.2270.0 directory and there you should see a file called install.sh.
To see a list of the available installation options, execute the following command: ./install.sh.
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 .
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.
When you’re 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.
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 .
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» .
Uninstall
You can uninstall the ODBC driver 11 on Linux by executing the following commands:
rm -f /usr/bin/sqlcmd
rm -rf /opt/microsoft/msodbcsql
odbcinst -u -d -n «ODBC Driver 11 for SQL Server»
Driver files
The ODBC driver on Linux consists of the following components:
Component | Description |
---|---|
libmsodbcsql-17.X.so.X.X or libmsodbcsql-13.X.so.X.X | The 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.rll | The accompanying resource file for the driver library. This file is installed in [driver .so directory]../share/resources/en_US/ |
msodbcsql.h | The header file that contains all of the new definitions needed to use the driver. Note: You can’t 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.txt | The 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_NOTES | The 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. |
Resource file loading
The driver needs to load the resource file 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 path on Linux is /opt/microsoft/msodbcsql17/share/resources/en_US/ .
Troubleshooting
If you’re unable to make a connection to SQL Server using the ODBC driver, see the known issues article on troubleshooting connection problems.
Next steps
After installing the driver, you can try the C++ ODBC example application. For more information about developing ODBC applications, see Developing Applications.
For more information, see the ODBC driver release notes and system requirements.
Источник
Установка Microsoft ODBC Driver for SQL Server (Linux)
В этой статье объясняется, как установить Microsoft ODBC Driver for SQL Server в Linux. В ней также содержатся инструкции для необязательных средств командной строки для SQL Server ( bcp и sqlcmd ) и заголовков разработки unixODBC.
В этой статье приведены команды для установки драйвера ODBC из оболочки bash. Сведения о том, как загрузить пакеты напрямую, см. в разделе Скачивание драйвера ODBC Driver for SQL Server.
Microsoft ODBC 17
В следующих разделах объясняется, как установить драйвер Microsoft ODBC 17 из оболочки bash в различных дистрибутивах Linux.
Если вы установили пакет msodbcsql версии 17, который был доступен непродолжительное время, его следует удалить перед установкой пакета msodbcsql17 . Это позволит избежать конфликтов. Пакет msodbcsql17 можно установить параллельно с пакетом msodbcsql версии 13.
Alpine Linux
Для поддержки Alpine требуется драйвер версии 17.5 или более поздней.
Debian
Вместо настройки переменной среды ACCEPT_EULA вы можете создать переменную debconf с именем «msodbcsql/ACCEPT_EULA»: echo msodbcsql17 msodbcsql/ACCEPT_EULA boolean true | sudo debconf-set-selections
Red Hat Enterprise Server и Oracle Linux
SUSE Linux Enterprise Server
Ubuntu
Вместо настройки переменной среды ACCEPT_EULA вы можете создать переменную debconf с именем «msodbcsql/ACCEPT_EULA»: echo msodbcsql17 msodbcsql/ACCEPT_EULA boolean true | sudo debconf-set-selections
Предыдущие версии
В следующих разделах приведены инструкции по установке предыдущих версий драйвера Microsoft ODBC в Linux. Рассматриваются следующие версии драйверов.
ODBC 13.1
В следующих разделах объясняется, как установить драйвер Microsoft ODBC 13.1 из оболочки bash в различных дистрибутивах Linux.
Debian 8
Red Hat Enterprise Server 6
Red Hat Enterprise Server 7
SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 12
Ubuntu 15.10
Ubuntu 16.04
Ubuntu 16.10
ODBC 13
В следующих разделах объясняется, как установить драйвер Microsoft ODBC 13 из оболочки bash в различных дистрибутивах Linux.
Red Hat Enterprise Server 6 (ODBC 13)
Red Hat Enterprise Server 7 (ODBC 13)
Ubuntu 15.10 (ODBC 13)
Ubuntu 16.04 (ODBC 13)
SUSE Linux Enterprise Server 12 (ODBC 13)
Автономная установка
Если необходимо установить драйвер Microsoft ODBC версии 13 на компьютере без подключения к Интернету, потребуется разрешить зависимости пакетов вручную. Драйвер Microsoft ODBC версии 13 имеет следующие прямые зависимости:
- 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
Каждый из этих пакетов, в свою очередь, имеет собственные зависимости, которые могут отсутствовать в системе. Для решения этой проблемы в общем случае следует обратиться к документации по диспетчеру пакетов используемого дистрибутива: Red Hat, Ubuntu и SUSE
Другое распространенное решение — вручную скачать все зависимые пакеты в одну папку на компьютере установки, а затем вручную установить каждый пакет по очереди, завершив пакетом драйвера Microsoft ODBC версии 13.
Red Hat Linux Enterprise Server 7
- Скачайте последнюю версию msodbcsql .rpm с сайта https://packages.microsoft.com/rhel/7/prod/.
- Установите зависимости и драйвер.
Ubuntu 16.04 (ODBC 13 в автономном режиме)
- Скачайте последнюю версию msodbcsql .deb с сайта https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/msodbcsql/.
- Установите зависимости и драйвер.
SUSE Linux Enterprise Server 12 (ODBC 13 в автономном режиме)
- Скачайте последнюю версию msodbcsql .rpm с сайта https://packages.microsoft.com/sles/12/prod/.
- Установите зависимости и драйвер.
После установки пакета можно проверить, находит ли драйвер Microsoft ODBC версии 13 все нужные зависимости. Для этого выполните команду ldd и проверьте наличие отсутствующих библиотек в выходных данных:
ODBC 11
В следующих разделах объясняется, как установить Microsoft ODBC Driver 11 в Linux. Для использования драйвера сначала установите диспетчер драйверов unixODBC. Дополнительные сведения: Установка диспетчера драйверов.
Процесс установки
Эти инструкции ссылаются на msodbcsql-11.0.2270.0.tar.gz (файл установки для Red Hat Linux). В случае установке предварительной версии для SUSE Linux файл называется msodbcsql-11.0.2260.0.tar.gz .
Порядок установки драйвера
Убедитесь, что у вас есть корневое разрешение.
Перейдите в каталог, куда был скачан файл с именем msodbcsql-11.0.2270.0.tar.gz . Убедитесь в наличии файла *.TAR.GZ, который соответствует вашей версии Linux. Чтобы извлечь файлы, выполните следующую команду: tar xvzf msodbcsql-11.0.2270.0.tar.gz .
Перейдите в каталог msodbcsql-11.0.2270.0 , где должен находиться файл install.sh.
Чтобы просмотреть список доступных параметров установки, выполните следующую команду: ./install.sh.
Создайте резервную копию odbcinst.ini. Установка драйвера обновляет odbcinst.ini. Файл odbcinst.ini содержит список драйверов, которые зарегистрированы с помощью диспетчера драйверов unixODBC. Чтобы определить на компьютере расположение файла odbcinst.ini, выполните следующую команду: odbc_config —odbcinstini .
Перед установкой драйвера выполните следующую команду: ./install.sh verify . Выходные данные команды ./install.sh verify показывают, есть ли на компьютере ПО, необходимое для поддержки драйвера ODBC на Linux.
Когда вы будете готовы установить драйвер ODBC на Linux, выполните команду: ./install.sh install . Если вам нужно будет дополнительно указать команду установки ( bin-dir или lib-dir ), сделайте это после параметра install.
После просмотра лицензионного соглашения введите YES для продолжения установки.
При установке драйвер помещается в папку /opt/microsoft/msodbcsql/11.0.2270.0 . Драйвер и его вспомогательные файлы должны находиться в папке /opt/microsoft/msodbcsql/11.0.2270.0 .
Для проверки, что драйвер ODBC в Linux зарегистрирован, выполните следующую команду: odbcinst -q -d -n «ODBC Driver 11 for SQL Server» .
Удаление
Вы можете удалить драйвер ODBC 11 на Linux, выполнив следующие команды:
rm -f /usr/bin/sqlcmd
rm -rf /opt/microsoft/msodbcsql
odbcinst -u -d -n «ODBC Driver 11 for SQL Server»
Файлы драйвера
Драйвер ODBC в Linux состоит из следующих компонентов.
Компонент | Описание |
---|---|
libmsodbcsql-17.X.so.X.X или libmsodbcsql-13.X.so.X.X | Общий объект ( so ) файла динамической библиотеки, содержащий все функциональные возможности драйвера. Этот файл устанавливается в папке /opt/microsoft/msodbcsql17/lib64/ для версии 17 драйвера и в папке /opt/microsoft/msodbcsql/lib64/ для версии 13. |
msodbcsqlr17.rll либо msodbcsqlr13.rll | Сопутствующий файл ресурса для библиотеки драйвера. Этот файл устанавливается в папке [driver .so directory]../share/resources/en_US/ . |
msodbcsql.h | Файл заголовка, содержащий все новые определения, необходимые для использования драйвера. Примечание. В одной программе нельзя ссылаться на msodbcsql.h и odbcss.h одновременно. Файл msodbcsql.h устанавливается в папке /opt/microsoft/msodbcsql17/include/ для версии 17 драйвера и в папке /opt/microsoft/msodbcsql/include/ для версии 13. |
LICENSE.txt | Текстовый файл с условиями лицензионного соглашения. Этот файл помещается в папку /usr/share/doc/msodbcsql17/ для версии 17 драйвера и в папку /usr/share/doc/msodbcsql/ для версии 13. |
RELEASE_NOTES | Текстовый файл с заметками о выпуске. Этот файл помещается в папку /usr/share/doc/msodbcsql17/ для версии 17 драйвера и в папку /usr/share/doc/msodbcsql/ для версии 13. |
Загрузка файла ресурсов
Для работы драйверу необходимо загрузить файл ресурсов. Этот файл имеет имя msodbcsqlr17.rll или msodbcsqlr13.rll в зависимости от версии драйвера. Файл .rll располагается по пути относительно расположения самого драйвера ( so или dylib ), указанного в таблице выше. Кроме того, начиная с версии 17.1 драйвер пытается загрузить файл .rll из каталога по умолчанию, если его не удалось загрузить по относительному пути. Путь к файлу ресурсов по умолчанию в Linux: /opt/microsoft/msodbcsql17/share/resources/en_US/ .
Устранение неполадок
Если не удается установить подключение к SQL Server с помощью драйвера ODBC, см. статью, посвященную известным проблемам при устранении неполадок подключения.
Дальнейшие действия
После установки драйвера можно попробовать пример приложения C++ ODBC. Подробнее о разработке приложений ODBC см. в разделе Разработка приложений.
Дополнительные сведения см. в статьях с заметками о выпуске и требованиями к системе для драйвера ODBC.
Источник