| title | Install SQL Server Tools on Linux - SQL Server vNext | Microsoft Docs |
|---|---|
| description | This topic describes how to install the SQL Server Tools on Linux. |
| author | rothja |
| ms.author | jroth |
| manager | jhubbard |
| ms.date | 12/16/2016 |
| ms.topic | article |
| ms.prod | sql-linux |
| ms.technology | database-engine |
| ms.assetid | eff8e226-185f-46d4-a3e3-e18b7a439e63 |
The following steps install the command-line tools, Microsoft ODBC drivers, and their dependencies. The mssql-tools package contains:
- sqlcmd: Command-line query utility.
- bcp: Bulk import-export utility.
Install the tools for your platform:
-
Enter superuser mode.
sudo su
-
Download the Microsoft Red Hat repository configuration file.
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo -
Exit superuser mode.
exit -
Run the following commands to install mssql-tools.
sudo yum install mssql-tools
Note
To update to the latest version of mssql-tools run the following commands:
yum check-update
yum update mssql-toolsOptional Step: Create symlinks to SQLCMD and BCP under /usr/bin/.
ln -sfn /opt/mssql-tools/bin/sqlcmd{Fill-Version-Here} /usr/bin/sqlcmd
ln -sfn /opt/mssql-tools/bin/bcp{Fill-Version-Here} /usr/bin/bcp-
Import the public repository GPG keys.
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - -
Register the Microsoft Ubuntu repository.
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list -
Update the sources list and run the installation command.
sudo apt-get update sudo apt-get upgrade mssql-tools
Note
To update to the latest version of mssql-tools run the following commands:
apt-get refresh
apt-get update mssql-toolsOptional Step: Create symlinks to SQLCMD and BCP under /usr/bin/.
ln -sfn /opt/mssql-tools/bin/sqlcmd{Fill-Version-Here} /usr/bin/sqlcmd
ln -sfn /opt/mssql-tools/bin/bcp{Fill-Version-Here} /usr/bin/bcp-
Enter superuser mode.
sudo su
-
Add the Microsoft SQL Server repository to Zypper.
zypper ar https://packages.microsoft.com/yumrepos/mssql-suse12-release/ "mssql" -
Download and import GPG keys.
wget "http://aka.ms/msodbcrhelpublickey/dpgswdist.v1.asc" rpm --import dpgswdist.v1.asc wget "https://apt-mo.trafficmanager.net/keys/microsoft.asc" rpm --import microsoft.asc
-
Exit superuser mode.
exit -
Update the sources and install mssql-tools.
sudo zypper update sudo zypper install mssql-tools
Note
To update to the latest version of mssql-tools run the following commands:
zypper refresh
zypper update mssql-toolsOptional Step: Create symlinks to SQLCMD and BCP under /usr/bin/.
ln -sfn /opt/mssql-tools/bin/sqlcmd{Fill-Version-Here} /usr/bin/sqlcmd
ln -sfn /opt/mssql-tools/bin/bcp{Fill-Version-Here} /usr/bin/bcpTip
In addition to accessing mssql-tools in its installed directory, you can access the tools anywhere by creating symlinks for ‘sqlcmd’ and ‘bcp’ To create a new symlink run: ln -s {path to target} {path to link} To update an existing symlink run: ln -sfn {path to target} {path to link}
Examples: Running ‘ln -s /opt/mssql-tools/bin/sqlcmd13.0.0.1 /usr/bin/sqlcmd’ will create a symlink to the sqlcmd13.0.0.1 binary under /usr/bin which a part of the PATH env variable by default. The ‘sqlcmd’ command will now launch the sqlcmd13.0.0.1 utility.
Running ‘ln -sfn /opt/mssql-tools/bin/sqlcmd13.0.0.1 /usr/bin/sqlcmd’ will update the existing /usr/bin/sqlcmd to point to /opt/mssql-tools/bin/sqlcmd13.0.0.1.
Sqlcmd and bcp are not available on macOS.
Use sql-cli from macOS. For more information, see sql-cli.
After installation, connect to the SQL Server instance to create and manage databases. To get started, see Connect and query SQL Server on Linux.