Install SQL Server tools on Linux

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:

Install tools on RHEL

  1. Enter superuser mode.

    sudo su
    
  2. Download the Microsoft Red Hat repository configuration file.

    curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
    
  3. Exit superuser mode.

    exit
    
  4. Run the following commands to install 'mssql-tools' with the unixODBC developer package.

    sudo yum update
    sudo yum install mssql-tools unixODBC-utf16-devel
    
Note

To update to the latest version of 'mssql-tools' run the following commands:

  yum check-update
  yum update mssql-tools

Optional Step: Create symlinks to 'SQLCMD' and 'BCP' under /usr/bin/.

   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

Install tools on Ubuntu

  1. Import the public repository GPG keys.

    curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
    
  2. 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
    
  3. Update the sources list and run the installation command with the unixODBC developer package.

    sudo apt-get update 
    sudo apt-get install mssql-tools unixodbc-dev-utf16
    
Note

To update to the latest version of 'mssql-tools' run the following commands:

  apt-get refresh
  apt-get update mssql-tools

Optional Step: Create symlinks to 'SQLCMD' and 'BCP' under /usr/bin/.

   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

Install tools on SLES

  1. Add the Microsoft SQL Server repository to Zypper.

    sudo zypper ar https://packages.microsoft.com/config/sles/12/prod.repo
    
  2. Update the sources, and install 'mssql-tools' with the unixODBC developer package.

    sudo zypper update
    sudo zypper install mssql-tools unixODBC-utf16-devel
    
Note

To update to the latest version of 'mssql-tools' run the following commands:

  zypper refresh
  zypper update mssql-tools

Optional Step: Create symlinks to 'SQLCMD' and 'BCP' under /usr/bin/.

   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

Install tools on macOS

Sqlcmd and bcp are not available on macOS.

Use sql-cli from macOS. For more information, see sql-cli.

Next steps

After installation, connect to the SQL Server instance to create and manage databases. To get started, see Connect and query SQL Server on Linux.