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.
To make sqlcmd and bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:
To make sqlcmd or bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:
To make sqlcmd and bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:
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-tools18
Install tools on Docker
If 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:
If 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.
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:
Resolve 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:
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:
Resolve 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:
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:
Resolve 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 install
This 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:
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.
SQL Server now runs on your choice of operating system. In this learning path, you'll discover the fundamentals of SQL Server on Linux, before discovering how to run SQL Server on Linux containers and deploy SQL Server on Linux. You'll then learn how to automatically tune your SQL Server on Linux deployment.
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.