Instalando o Microsoft ODBC Driver for SQL Server no Linux e no macOSInstalling the Microsoft ODBC Driver for SQL Server on Linux and macOS

BaixarBaixar o driver ODBCDownloadDownload ODBC Driver

Este artigo explica como instalar o MicrosoftMicrosoft ODBC Driver for SQL ServerSQL Server no Linux e no macOS, bem como as Ferramentas de Linha de Comando opcionais para o SQL Server (bcp e sqlcmd) e os Cabeçalhos de Desenvolvimento unixODBC.This article explains how to install the MicrosoftMicrosoft ODBC Driver for SQL ServerSQL 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 ServerMicrosoft ODBC Driver 17 for SQL Server

Importante

Se você tiver instalado o pacote v17 msodbcsql que estava disponível brevemente, deverá removê-lo antes de instalar o pacote msodbcsql17.If you installed the v17 msodbcsql package that was briefly available, you should remove it before installing the msodbcsql17 package. Isso evitará conflitos.This will avoid conflicts. O pacote msodbcsql17 pode ser instalado lado a lado com o pacote msodbcsql v13.The msodbcsql17 package can be installed side by side with the msodbcsql v13 package.

DebianDebian

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#Debian 8
curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Debian 9
curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Debian 10
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list

exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev

RedHat Enterprise ServerRedHat Enterprise Server

sudo su

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#RedHat Enterprise Server 6
curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo

#RedHat Enterprise Server 7
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo

#RedHat Enterprise Server 8
curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/mssql-release.repo

exit
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
sudo ACCEPT_EULA=Y yum install msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y yum install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo yum install unixODBC-devel

SUSE Linux Enterprise ServerSUSE Linux Enterprise Server

sudo su

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#SUSE Linux Enterprise Server 11 SP4
#Ensure SUSE Linux Enterprise 11 Security Module has been installed 
zypper ar https://packages.microsoft.com/config/sles/11/prod.repo

#SUSE Linux Enterprise Server 12
zypper ar https://packages.microsoft.com/config/sles/12/prod.repo

#SUSE Linux Enterprise Server 15
zypper ar https://packages.microsoft.com/config/sles/15/prod.repo
#(Only for driver 17.3 and below)
SUSEConnect -p sle-module-legacy/15/x86_64

exit
sudo ACCEPT_EULA=Y zypper install msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y zypper install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo zypper install unixODBC-devel

UbuntuUbuntu

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version

#Ubuntu 14.04
curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 16.04
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 18.04
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 18.10
curl https://packages.microsoft.com/config/ubuntu/18.10/prod.list > /etc/apt/sources.list.d/mssql-release.list

#Ubuntu 19.04
curl https://packages.microsoft.com/config/ubuntu/19.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev

Observação

  • Versão do driver 17.2 ou posterior é necessária para suporte ao Ubuntu 18.04.Driver version 17.2 or higher is required for Ubuntu 18.04 support.
  • Versão do driver 17.3 ou posterior é necessária para suporte ao Ubuntu 18.10.Driver version 17.3 or higher is required for Ubuntu 18.10 support.

MacOSMacOS

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install msodbcsql17 mssql-tools

Microsoft ODBC Driver 13.1 for SQL ServerMicrosoft ODBC Driver 13.1 for SQL Server

Debian 8Debian 8

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev

RedHat Enterprise Server 6RedHat Enterprise Server 6

sudo su
curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
sudo ACCEPT_EULA=Y yum install msodbcsql
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y yum install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo yum install unixODBC-devel

RedHat Enterprise Server 7RedHat Enterprise Server 7

sudo su
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel #to avoid conflicts
sudo ACCEPT_EULA=Y yum install msodbcsql
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y yum install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo yum install unixODBC-devel

SUSE Linux Enterprise Server 11SUSE Linux Enterprise Server 11

sudo su
zypper ar https://packages.microsoft.com/config/sles/11/prod.repo
exit
sudo ACCEPT_EULA=Y zypper install msodbcsql
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y zypper install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo zypper install unixODBC-devel

SUSE Linux Enterprise Server 12SUSE Linux Enterprise Server 12

sudo su
zypper ar https://packages.microsoft.com/config/sles/12/prod.repo
exit
sudo ACCEPT_EULA=Y zypper install msodbcsql
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y zypper install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo zypper install unixODBC-devel

Ubuntu 15.10Ubuntu 15.10

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/15.10/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev

Ubuntu 16.04Ubuntu 16.04

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev

Ubuntu 16.10Ubuntu 16.10

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.10/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev

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

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release
brew update
brew install msodbcsql@13.1.9.2 mssql-tools@14.0.6.0

Microsoft ODBC Driver 13 for SQL ServerMicrosoft ODBC Driver 13 for SQL Server

RedHat Enterprise Server 6RedHat Enterprise Server 6

sudo su
curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit
sudo yum update
sudo yum remove unixODBC #to avoid conflicts
sudo ACCEPT_EULA=Y yum install msodbcsql-13.0.1.0-1 mssql-tools-14.0.2.0-1
sudo yum install unixODBC-utf16-devel #this step is optional but recommended*
#Create symlinks for tools
ln -sfn /opt/mssql-tools/bin/sqlcmd-13.0.1.0 /usr/bin/sqlcmd 
ln -sfn /opt/mssql-tools/bin/bcp-13.0.1.0 /usr/bin/bcp

RedHat Enterprise Server 7RedHat Enterprise Server 7

sudo su
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit
sudo yum update
sudo yum remove unixODBC #to avoid conflicts
sudo ACCEPT_EULA=Y yum install msodbcsql-13.0.1.0-1 mssql-tools-14.0.2.0-1
sudo yum install unixODBC-utf16-devel #this step is optional but recommended*
#Create symlinks for tools
ln -sfn /opt/mssql-tools/bin/sqlcmd-13.0.1.0 /usr/bin/sqlcmd 
ln -sfn /opt/mssql-tools/bin/bcp-13.0.1.0 /usr/bin/bcp

Ubuntu 15.10Ubuntu 15.10

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/15.10/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql=13.0.1.0-1 mssql-tools=14.0.2.0-1
sudo apt-get install unixodbc-dev-utf16 #this step is optional but recommended*
#Create symlinks for tools
ln -sfn /opt/mssql-tools/bin/sqlcmd-13.0.1.0 /usr/bin/sqlcmd 
ln -sfn /opt/mssql-tools/bin/bcp-13.0.1.0 /usr/bin/bcp

Ubuntu 16.04Ubuntu 16.04

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql=13.0.1.0-1 mssql-tools=14.0.2.0-1
sudo apt-get install unixodbc-dev-utf16 #this step is optional but recommended*
#Create symlinks for tools
ln -sfn /opt/mssql-tools/bin/sqlcmd-13.0.1.0 /usr/bin/sqlcmd 
ln -sfn /opt/mssql-tools/bin/bcp-13.0.1.0 /usr/bin/bcp

SUSE Linux Enterprise Server 12SUSE Linux Enterprise Server 12

sudo su 
zypper ar https://packages.microsoft.com/config/sles/12/prod.repo 
zypper update 
sudo ACCEPT_EULA=Y zypper install msodbcsql-13.0.1.0-1 mssql-tools-14.0.2.0-1
zypper install unixODBC-utf16-devel
#Create symlinks for tools
ln -sfn /opt/mssql-tools/bin/sqlcmd-13.0.1.0 /usr/bin/sqlcmd 
ln -sfn /opt/mssql-tools/bin/bcp-13.0.1.0 /usr/bin/bcp

Instalação offlineOffline installation

Se você preferir/precisar que o MicrosoftMicrosoft ODBC Driver 13 seja instalado em um computador sem conexão de Internet, precisará resolver as dependências do pacote manualmente.If you prefer/require the MicrosoftMicrosoft ODBC Driver 13 to be installed on a computer with no internet connection, you will need to resolve package dependencies manually. O MicrosoftMicrosoft ODBC Driver 13 tem as seguintes dependências diretas:The MicrosoftMicrosoft 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)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, unixODBCRed Hat: glibc, e2fsprogs, krb5-libs, openssl, unixODBC
  • SuSE: glibc, libuuid1, krb5, openssl, unixODBCSuSE: glibc, libuuid1, krb5, openssl, unixODBC

Por sua vez, cada um desses pacotes tem suas próprias dependências, que podem ou não estar presentes no sistema.Each of these packages in turn has their own dependencies, which may or may not be present on the system. Para uma solução geral para esse problema, veja a documentação do gerenciador de pacotes de distribuição: Red Hat, Ubuntu e SUSEFor a general solution to this issue, refer to your distribution's package manager documentation: Redhat, Ubuntu, and SUSE

Também é comum baixar manualmente todos os pacotes dependentes e colocá-los juntos no computador de instalação, então instalar manualmente cada pacote por vez, terminando com o pacote MicrosoftMicrosoft ODBC Driver 13.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 MicrosoftMicrosoft ODBC Driver 13 package.

Redhat Linux Enterprise Server 7Redhat Linux Enterprise Server 7

yum install glibc e2fsprogs krb5-libs openssl unixODBC unixODBC-devel #install dependencies
sudo rpm -i  msodbcsql-13.1.X.X-X.x86_64.rpm #install the Driver

Ubuntu 16.04Ubuntu 16.04

sudo apt-get install libc6 libstdc++6 libkrb5-3 libcurl3 openssl debconf unixodbc unixodbc-dev #install dependencies
sudo dpkg -i msodbcsql_13.1.X.X-X_amd64.deb #install the Driver

SUSE Linux Enterprise Server 12SUSE Linux Enterprise Server 12

zypper install glibc, libuuid1, krb5, openssl, unixODBC unixODBC-devel #install dependencies
sudo rpm -i  msodbcsql-13.1.X.X-X.x86_64.rpm #install the Driver

Depois de concluir a instalação do pacote, pode verificar se o MicrosoftMicrosoft ODBC Driver 13 pode encontrar todas as suas dependências executando ldd e inspecionando sua saída quanto a bibliotecas ausentes:Once you have completed the package installation, you can verify that the MicrosoftMicrosoft ODBC Driver 13 can find all its dependencies by running ldd and inspecting its output for missing libraries:

ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-*

Microsoft ODBC Driver 11 para SQL Server em LinuxMicrosoft ODBC Driver 11 for SQL Server on Linux

Antes de poder usar o driver, instale o Gerenciador de Driver unixODBC.Before you can use the driver, install the unixODBC driver manager. Para obter mais informações, veja Instalação do Gerenciador de Driver.For more information, see Installing the Driver Manager.

Etapas da instalaçãoInstallation Steps

Importante

Estas instruções referem-se ao msodbcsql-11.0.2270.0.tar.gz, que é o arquivo de instalação para o Red Hat Linux.These instructions refer to msodbcsql-11.0.2270.0.tar.gz, which is installation file for Red Hat Linux. Se estiver instalando a Versão Prévia para SUSE Linux, o nome do arquivo será msodbcsql-11.0.2260.0.tar.gz.If you are installing the Preview for SUSE Linux, the file name is msodbcsql-11.0.2260.0.tar.gz.

Para instalar o driver:To install the driver:

  1. Verifique se você tem permissão de raiz.Make sure that you have root permission.

  2. Altere o diretório em que o download colocou o arquivo msodbcsql-11.0.2270.0.tar.gz.Change to the directory where the download placed the file msodbcsql-11.0.2270.0.tar.gz. Verifique se você tem o arquivo *.tar.gz que corresponde à sua versão do Linux.Make sure that you have the *.tar.gz file that matches your version of Linux. Para extrair os arquivos, execute o seguinte comando: tar xvzf msodbcsql-11.0.2270.0.tar.gz.To extract the files, execute the following command, tar xvzf msodbcsql-11.0.2270.0.tar.gz.

  3. Altere para o diretório msodbcsql-11.0.2270.0. Lá, você deverá ver um arquivo chamado install.sh.Change to the msodbcsql-11.0.2270.0 directory and there you should see a file called install.sh.

  4. Para ver uma lista das opções de instalação disponíveis, execute o seguinte comando: ./install.sh.To see a list of the available installation options, execute the following command: ./install.sh.

  5. Faça um backup de odbcinst.ini.Make a backup of odbcinst.ini. A instalação do driver atualiza o odbcinst.ini.The driver installation updates odbcinst.ini. O odbcinst.ini contém a lista de drivers que estão registrados com o Gerenciador de Driver unixODBC.odbcinst.ini contains the list of drivers that are registered with the unixODBC Driver Manager. Para descobrir a localização do odbcinst.ini em seu computador, execute o seguinte comando: odbc_config --odbcinstini.To discover the location of odbcinst.ini on your computer, execute the following command: odbc_config --odbcinstini.

  6. Antes de instalar o driver, execute o seguinte comando: ./install.sh verify.Before you install the driver, execute the following command: ./install.sh verify. A saída de ./install.sh verify informa se o seu computador tem o software necessário para suporte ao driver ODBC em Linux.The output of ./install.sh verify reports if your computer has the required software to support the ODBC driver on Linux.

  7. Quando estiver pronto para instalar o driver ODBC no Linux, execute o comando: ./install.sh install.When you are ready to install the ODBC driver on Linux, execute the command: ./install.sh install. Se precisar especificar um comando de instalação (bin-dir ou lib-dir), especifique o comando após a opção install.If you need to specify an install command (bin-dir or lib-dir), specify the command after the install option.

  8. Depois de ler o contrato de licença, digite YES para continuar com a instalação.After reviewing the license agreement, type YES to continue with the installation.

A instalação coloca o driver em /opt/microsoft/msodbcsql/11.0.2270.0.Installation puts the driver in /opt/microsoft/msodbcsql/11.0.2270.0. O driver e seus arquivos de suporte devem estar no /opt/microsoft/msodbcsql/11.0.2270.0.The driver and its support files must be in /opt/microsoft/msodbcsql/11.0.2270.0.

Para verificar se o driver Microsoft ODBC em Linux foi registrado com êxito, execute o seguinte comando: odbcinst -q -d -n "ODBC Driver 11 for SQL Server".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 exibe um exemplo de código que se conecta ao SQL ServerSQL Server usando o driver ODBC no Linux.Use Existing MSDN C++ ODBC Samples for the ODBC Driver on Linux shows a code sample that connects to SQL ServerSQL Server using the ODBC driver on Linux.

DesinstalandoUninstalling

Você pode desinstalar o ODBC Driver 11 no Linux executando os seguintes comandos: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"

Solucionando problemas de conexãoTroubleshooting Connection Problems

Se não for possível estabelecer uma conexão com o SQL ServerSQL Server usando o driver ODBC, use as informações a seguir para identificar o problema.If you are unable to make a connection to SQL ServerSQL Server using the ODBC driver, use the following information to identify the problem.

O problema de conexão mais comum é ter duas cópias do Gerenciador de Driver UnixODBC instaladas.The most common connection problem is to have two copies of the UnixODBC Driver Manager installed. Pesquise por libodbc*.so*em /usr.Search /usr for libodbc*.so*. Se houver mais de uma versão do arquivo, você (possivelmente) tem mais de um gerenciador de driver instalado.If you see more than one version of the file, you (possibly) have more than one driver manager installed. Seu aplicativo pode usar a versão errada.Your application might use the wrong version.

Habilite o log de conexão editando seu arquivo /etc/odbcinst.ini para conter a seção a seguir com estes itens:Enable the connection log by editing your /etc/odbcinst.ini file to contain the following section with these items:

[ODBC]
Trace = Yes
TraceFile = (path to log file, or /dev/stdout to output directly to the terminal)

Se você obtiver outra falha de conexão e não vir um arquivo de log, (possivelmente) há duas cópias do Gerenciador de Driver em seu computador.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. Caso contrário, a saída do log deve ser semelhante ao seguinte:Otherwise, the log output should be similar to the following:

[ODBC][28783][1321576347.077780][SQLDriverConnectW.c][290]  
        Entry:  
            Connection = 0x17c858e0  
            Window Hdl = (nil)  
            Str In = [DRIVER={ODBC Driver 13 for SQL Server};SERVER={contoso.com};Trusted_Connection={YES};WSID={mydb.contoso.com};AP...][length = 139 (SQL_NTS)]  
            Str Out = (nil)  
            Str Out Max = 0  
            Str Out Ptr = (nil)  
            Completion = 0  
        UNICODE Using encoding ASCII 'UTF8' and UNICODE 'UTF16LE'  

Se a codificação de caracteres ASCII não for UTF-8, por exemplo:If the ASCII character encoding is not UTF-8, for example:

UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE 'UCS-2LE'  

Há mais de um Gerenciador de Driver instalado e o seu aplicativo está usando o errado ou o Gerenciador de Driver não foi compilado corretamente.There is more than one Driver Manager installed and your application is using the wrong one, or the Driver Manager was not built correctly.

Para obter mais informações sobre como resolver falhas de conexão, consulte:For more information about resolving connection failures, see:

Arquivos do driverDriver Files

O Driver ODBC em Linux e MacOS consiste nos seguintes componentes:The ODBC Driver on Linux and MacOS consists of the following components:

LinuxLinux

ComponenteComponent DescriçãoDescription
libmsodbcsql-17.X.so.X.X ou libmsodbcsql-13.X.so.X.Xlibmsodbcsql-17.X.so.X.X or libmsodbcsql-13.X.so.X.X O arquivo de biblioteca dinâmica (so) do objeto compartilhado que contém toda a funcionalidade do driver.The shared object (so) dynamic library file that contains all of the driver's functionality. Esse arquivo é instalado em /opt/microsoft/msodbcsql17/lib64/ para o Driver 17 e em /opt/microsoft/msodbcsql/lib64/ para o Driver 13.This file is installed in /opt/microsoft/msodbcsql17/lib64/ for the Driver 17 and in /opt/microsoft/msodbcsql/lib64/ for Driver 13.
msodbcsqlr17.rll ou msodbcsqlr13.rllmsodbcsqlr17.rll or msodbcsqlr13.rll O arquivo de recursos que acompanha a biblioteca do driver.The accompanying resource file for the driver library. Esse arquivo é instalado em [driver .so directory]../share/resources/en_US/This file is installed in [driver .so directory]../share/resources/en_US/
msodbcsql.hmsodbcsql.h O arquivo de cabeçalho que contém todas as novas definições necessárias para usar o driver.The header file that contains all of the new definitions needed to use the driver.

Observação: você não pode referenciar msodbcsql.h e odbcss.h no mesmo programa.Note: You cannot reference msodbcsql.h and odbcss.h in the same program.

msodbcsql.h é instalado em /opt/microsoft/msodbcsql17/include/ para o Driver 17 e em /opt/microsoft/msodbcsql/include/ para o Driver 13.msodbcsql.h is installed in /opt/microsoft/msodbcsql17/include/ for Driver 17 and in /opt/microsoft/msodbcsql/include/ for Driver 13.
LICENSE.txtLICENSE.txt O arquivo de texto que contém os termos do Contrato de Licença do Usuário Final.The text file that contains the terms of the End-User License Agreement. Esse arquivo é colocado no /usr/share/doc/msodbcsql17/ para o Driver 17 e em /usr/share/doc/msodbcsql/ para o Driver 13.This file is placed in /usr/share/doc/msodbcsql17/ for Driver 17 and in /usr/share/doc/msodbcsql/ for Driver 13.
RELEASE_NOTESRELEASE_NOTES O arquivo de texto que contém as notas sobre a versão.The text file that contains release notes. Esse arquivo é colocado no /usr/share/doc/msodbcsql17/ para o Driver 17 e em /usr/share/doc/msodbcsql/ para o Driver 13.This file is placed in /usr/share/doc/msodbcsql17/ for Driver 17 and in /usr/share/doc/msodbcsql/ for Driver 13.

MacOSMacOS

ComponenteComponent DescriçãoDescription
libmsodbcsql.17.dylib ou libmsodbcsql.13.dyliblibmsodbcsql.17.dylib or libmsodbcsql.13.dylib O arquivo de biblioteca dinâmica (dylib) que contém toda a funcionalidade do driver.The dynamic library (dylib) file that contains all of the driver's functionality. Esse arquivo é instalado em /usr/local/lib/.This file is installed in /usr/local/lib/.
msodbcsqlr17.rll ou msodbcsqlr13.rllmsodbcsqlr17.rll or msodbcsqlr13.rll O arquivo de recursos que acompanha a biblioteca do driver.The accompanying resource file for the driver library. Esse arquivo é instalado em [driver .dylib directory]../share/msodbcsql17/resources/en_US/ para o Driver 17 e em [driver .dylib directory]../share/msodbcsql/resources/en_US/ para o Driver 13.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.hmsodbcsql.h O arquivo de cabeçalho que contém todas as novas definições necessárias para usar o driver.The header file that contains all of the new definitions needed to use the driver.

Observação: você não pode referenciar msodbcsql.h e odbcss.h no mesmo programa.Note: You cannot reference msodbcsql.h and odbcss.h in the same program.

msodbcsql.h é instalado em /usr/local/include/msodbcsql17/ para o Driver 17 e em /usr/local/include/msodbcsql/ para o Driver 13.msodbcsql.h is installed in /usr/local/include/msodbcsql17/ for Driver 17 and in /usr/local/include/msodbcsql/ for Driver 13.
LICENSE.txtLICENSE.txt O arquivo de texto que contém os termos do Contrato de Licença do Usuário Final.The text file that contains the terms of the End-User License Agreement. Esse arquivo é colocado no /usr/local/share/doc/msodbcsql17/ para o Driver 17 e em /usr/local/share/doc/msodbcsql/ para o Driver 13.This file is placed in /usr/local/share/doc/msodbcsql17/ for Driver 17 and in /usr/local/share/doc/msodbcsql/ for Driver 13.
RELEASE_NOTESRELEASE_NOTES O arquivo de texto que contém as notas sobre a versão.The text file that contains release notes. Esse arquivo é colocado no /usr/local/share/doc/msodbcsql17/ para o Driver 17 e em /usr/local/share/doc/msodbcsql/ para o Driver 13.This file is placed in /usr/local/share/doc/msodbcsql17/ for Driver 17 and in /usr/local/share/doc/msodbcsql/ for Driver 13.

Carregamento de arquivo de recursosResource File Loading

O driver precisa carregar o arquivo de recurso para funcionar.The driver needs to load the resource file in order to function. Esse arquivo é denominado msodbcsqlr17.rll ou msodbcsqlr13.rll, dependendo da versão do driver.This file is called msodbcsqlr17.rll or msodbcsqlr13.rll depending on the driver version. O local do arquivo .rll é relativo ao local do driver em si (so ou dylib), conforme observado na tabela acima.The location of the .rll file is relative to the location of the driver itself (so or dylib), as noted in the table above. A partir da versão 17.1, o driver também tentará carregar o .rll do diretório padrão se o carregamento do caminho relativo falhar.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. Os caminhos de arquivo de recurso padrão são:The default resource file paths are:

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

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

Consulte TambémSee Also

Instalando o Gerenciador de DriverInstalling the Driver Manager

Notas de versãoRelease Notes

Requisitos do sistemaSystem Requirements