This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: SQL Server on Linux
The following steps install the command-line tools, Microsoft ODBC drivers, and their dependencies. The mssql-tools package contains:
Install the tools for your platform:
This article describes how to install the command-line tools. If you're looking for examples of how to use sqlcmd or bcp, see the Related content at the end of this article.
Important
sqlcmd and bcp are available in mssql-tools18 for x64 and arm64 architectures. For a modern alternative across Linux, macOS, and Windows, see go-sqlcmd utility.
These instructions are for installing the Microsoft ODBC 18 packages. For previous versions, see Install the Microsoft ODBC driver for SQL Server (Linux).
Use the following steps to install the mssql-tools18 on Red Hat Enterprise Linux.
Download the Microsoft Red Hat repository configuration file.
For Red Hat 10, use the following command to download the Microsoft Red Hat repository configuration file from the RHEL 9 repo. The same versions of tools also work for RHEL 10.
curl https://packages.microsoft.com/config/rhel/9/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repoFor Red Hat 9, use the following command:
curl https://packages.microsoft.com/config/rhel/9/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repoFor Red Hat 8, use the following command:
curl https://packages.microsoft.com/config/rhel/8/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repoFor Red Hat 7, use the following command:
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/mssql-release.repoIf you had a previous version of mssql-tools installed, remove any older unixODBC packages.
sudo yum remove mssql-tools unixODBC-utf16 unixODBC-utf16-develRun the following commands to install mssql-tools18 with the unixODBC developer package.
sudo yum install -y mssql-tools18 unixODBC-develTo update to the latest version of mssql-tools, run the following commands:
sudo yum check-update sudo yum update mssql-tools18Optional: Add /opt/mssql-tools18/bin/ to your PATH environment variable in a Bash shell.
To make sqlcmd and bcp accessible from the Bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bash_profile source ~/.bash_profileTo make sqlcmd and bcp accessible from the Bash shell for interactive and non-login sessions, modify the PATH in the ~/.bashrc file with the following command:
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc source ~/.bashrcUse the following steps to install mssql-tools18 on SUSE Linux Enterprise Server.
Note
Starting in SQL Server 2025 (17.x), SUSE Linux Enterprise Server (SLES) isn't supported.
Import the Microsoft package signing key.
curl -O https://packages.microsoft.com/keys/microsoft.asc sudo rpm --import microsoft.ascAdd the SQL Server repository to Zypper.
For SLES 15, use the following command:
sudo zypper ar https://packages.microsoft.com/config/sles/15/prod.repoFor SLES 12, use the following command:
sudo zypper ar https://packages.microsoft.com/config/sles/12/prod.repoInstall mssql-tools18 with the unixODBC developer package.
To update to the latest version of mssql-tools18, run the following commands:
sudo zypper refresh sudo zypper update mssql-tools18Optional: Add /opt/mssql-tools18/bin/ to your PATH environment variable in a Bash shell.
To make sqlcmd and bcp accessible from the Bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bash_profile source ~/.bash_profileTo make sqlcmd and bcp accessible from the Bash shell for interactive and non-login sessions, modify the PATH in the ~/.bashrc file with the following command:
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc source ~/.bashrcUse the following steps to install the mssql-tools18 on Ubuntu.
Enter superuser mode.
sudo suImport the public repository GPG keys.
curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.ascRegister the Microsoft Ubuntu repository.
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | tee /etc/apt/sources.list.d/mssql-release.listExit superuser mode.
exitEnter superuser mode.
sudo suImport the public repository GPG keys.
curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.ascRegister the Microsoft Ubuntu repository.
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | tee /etc/apt/sources.list.d/mssql-release.listExit superuser mode.
exitEnter superuser mode.
sudo suImport the public repository GPG keys.
curl https://packages.microsoft.com/keys/microsoft.asc | tee /etc/apt/trusted.gpg.d/microsoft.ascRegister the Microsoft Ubuntu repository.
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | tee /etc/apt/sources.list.d/mssql-release.listExit superuser mode.
exitUse the following steps to install the mssql-tools18 for SQL Server 2025 (17.x) on Ubuntu 24.04.
Enter superuser mode.
sudo suRegister the Microsoft repository for Ubuntu 24.04.
curl -sSL -O https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.debInstall the repository package:
sudo dpkg -i packages-microsoft-prod.debExit superuser mode.
exitUpdate the sources list and run the installation command with the unixODBC developer package.
sudo apt-get update sudo apt-get install mssql-tools18 unixodbc-devTo update to the latest version of mssql-tools, run the following commands:
sudo apt-get update sudo apt-get install mssql-tools18Optional: Add /opt/mssql-tools18/bin/ to your PATH environment variable in a Bash shell.
To make sqlcmd and bcp accessible from the Bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bash_profile source ~/.bash_profileTo make sqlcmd and bcp accessible from the Bash shell for interactive and non-login sessions, modify the PATH in the ~/.bashrc file with the following command:
echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc source ~/.bashrcInstall Homebrew if you don't have it already:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"To install the tools for macOS El Capitan and later versions, use the following commands:
# brew untap microsoft/mssql-preview if you installed the preview version brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release brew update brew install mssql-tools18If you run SQL Server in a Docker container, the SQL Server command-line tools are already included in the SQL Server Linux container image. If you attach to a running container with an interactive Bash shell, you can run the tools locally.
If you're creating a container with the SQL Server command-line tools, you should add ACCEPT_EULA=Y to the installation command to silently accept the EULA, and not interrupt image creation. An example final command as part of installation on an Ubuntu-based image is:
sudo ACCEPT_EULA=Y apt-get install mssql-tools18 unixodbc-devIf your Linux machine doesn't have access to the online repositories used in the previous sections, you can download the package files directly. These packages are located in the Microsoft repository at https://packages.microsoft.com.
Tip
If you successfully installed with the steps in the previous sections, you don't need to download or manually install the following packages. This is only for the offline scenario.
First, locate and copy the mssql-tools18 package for your Linux distribution. For Red Hat 8.0, this package is located at https://packages.microsoft.com/rhel/8/prod.
Also locate and copy the msodbcsql18 package, which is a dependency. The msodbcsql18 package also has a dependency on unixODBC-devel. For Red Hat, the msodbcsql18 package is located at https://packages.microsoft.com/rhel/8/prod.
Move the downloaded packages to your Linux machine. If you used a different machine to download the packages, one way to move the packages to your Linux machine is with the scp command.
Install the and packages: Install the mssql-tools18 and msodbc18 packages. If you get any dependency errors, ignore them until the next step. Replace <version> with the correct version:
sudo yum localinstall msodbcsql18-<version>.rpm sudo yum localinstall mssql-tools18-<version>.rpmResolve missing dependencies: You might have missing dependencies at this point. If not, you can skip this step. In some cases, you must manually locate and install these dependencies.
You can inspect the required dependencies with the following commands. Replace <version> with the correct version:
rpm -qpR msodbcsql18-<version>.rpm rpm -qpR mssql-tools18-<version>.rpmNote
Starting in SQL Server 2025 (17.x), SUSE Linux Enterprise Server (SLES) isn't supported.
First, locate and copy the mssql-tools18 package for your Linux distribution. For SLES 15, this package is located at https://packages.microsoft.com/sles/15/prod.
Also locate and copy the msodbcsql18 package, which is a dependency. The msodbcsql18 package also has a dependency on unixODBC-devel. For SLES, the msodbcsql18 package is located at https://packages.microsoft.com/sles/15/prod.
Move the downloaded packages to your Linux machine. If you used a different machine to download the packages, one way to move the packages to your Linux machine is with the scp command.
Install the and packages: Install the mssql-tools18 and msodbc18 packages. If you get any dependency errors, ignore them until the next step. Replace <version> with the correct version:
sudo zypper install msodbcsql18-<version>.rpm sudo zypper install mssql-tools18-<version>.rpmResolve missing dependencies: You might have missing dependencies at this point. If not, you can skip this step. In some cases, you must manually locate and install these dependencies.
You can inspect the required dependencies with the following commands. Replace <version> with the correct version:
rpm -qpR msodbcsql18-<version>.rpm rpm -qpR mssql-tools18-<version>.rpmFirst, locate and copy the mssql-tools18 package for your Linux distribution. For Ubuntu 20.04, this package is located at https://packages.microsoft.com/ubuntu/20.04/prod/pool/main/m/mssql-tools.
Also locate and copy the msodbcsql18 package, which is a dependency. The msodbcsql18 package also has a dependency on unixodbc-dev. For Ubuntu, the msodbcsql18 packages are located at msodbcsql18, and unixodbc-dev.
Move the downloaded packages to your Linux machine. If you used a different machine to download the packages, one way to move the packages to your Linux machine is with the scp command.
Install the and packages: Install the mssql-tools18 and msodbc18 packages. If you get any dependency errors, ignore them until the next step. Replace <version> with the correct version:
sudo dpkg -i msodbcsql18_<version>.deb sudo dpkg -i mssql-tools18_<version>.debResolve missing dependencies: You might have missing dependencies at this point. If not, you can skip this step. In some cases, you must manually locate and install these dependencies.
If you have access to approved repositories containing those dependencies, the easiest solution is to use the apt-get command:
sudo apt-get -f installThis command completes the installation of the SQL Server packages as well.
If this step doesn't work for your Debian package, you can inspect the required dependencies with the following commands:
dpkg -I msodbcsql18_<version>_amd64.deb | grep "Depends:" dpkg -I mssql-tools18_<version>_amd64.deb | grep "Depends:"Did you know that you can edit SQL content yourself? If you do so, not only do you help improve our documentation, but you also get credited as a contributor to the page.
For more information, see Edit Microsoft Learn documentation.
Was this page helpful?
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?