Install Dev C++ Ubuntu Command Line

-->

APPLIES TO: SQL Server (Linux only) Azure SQL Database Azure Synapse Analytics (SQL DW) Parallel Data Warehouse

Install libjson-c-dev. Installing libjson-c-dev package on Ubuntu 14.04 (Trusty Tahr) is as easy as running the following command on terminal: sudo apt-get update sudo apt-get install libjson-c-dev.

  • Referring to Ask Ubuntu question How to set JAVAHOME for OpenJDK? How to install Open JDK (Java developement kit) in Ubuntu (Linux)? Open Terminal from Application Dash or press Ctrl+Alt+T. Update repository: sudo add-apt-repository ppa:openjdk-r/ppa # only Ubuntu 17.4 and earlier sudo apt update Optional: To search available distributions of openjdk, use the following.
  • Mar 30, 2012 “How to install an application in Ubuntu” The Most asked question by the majority of newbie. People who have migrated from windows to Ubuntu or trying their luck with Ubuntu, the basic problem they face is installing software on Ubuntu.

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:

This article describes how to install the command-line tools. If you are looking for examples of how to use sqlcmd or bcp, see the links at the end of this topic.

Install tools on RHEL 7

Use the following steps to install the mssql-tools on Red Hat Enterprise Linux.

Install Dev C++ Ubuntu Command Line
  1. Enter superuser mode.

  2. Download the Microsoft Red Hat repository configuration file.

  3. Exit superuser mode.

  4. If you had a previous version of mssql-tools installed, remove any older unixODBC packages.

  5. Run the following commands to install mssql-tools with the unixODBC developer package.

    Note

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

  6. Optional: Add /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell.

    To make sqlcmd/bcp accessible from the bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:

    To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:

Install tools on Ubuntu 16.04

Use the following steps to install the mssql-tools on Ubuntu.

Note

Install Dev C++ Ubuntu Command Line

Ubuntu 18.04 is supported starting with SQL Server 2019 CU3. If you are using Ubuntu 18.04, change the repository path from /ubuntu/16.04 to /ubuntu/18.04.

  1. Import the public repository GPG keys.

  2. Register the Microsoft Ubuntu repository.

  3. Update the sources list and run the installation command with the unixODBC developer package.

    Note

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

  4. Optional: Add /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell.

    To make sqlcmd/bcp accessible from the bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:

    To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:

Install tools on SLES 12

Use the following steps to install the mssql-tools on SUSE Linux Enterprise Server.

  1. Add the Microsoft SQL Server repository to Zypper.

  2. Install mssql-tools with the unixODBC developer package.

    Note

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

  3. Optional: Add /opt/mssql-tools/bin/ to your PATH environment variable in a bash shell.

    To make sqlcmd/bcp accessible from the bash shell for login sessions, modify your PATH in the ~/.bash_profile file with the following command:

    To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions, modify the PATH in the ~/.bashrc file with the following command:

Install tools on macOS

A preview of sqlcmd and bcp is now available on macOS. For more information, see the announcement.

Install Homebrew if you don't have it already:

To install the tools for Mac El Capitan and Sierra, use the following commands:

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.

Offline installation

If your Linux machine does not 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, https://packages.microsoft.com.

Tip

If you successfully installed with the steps in the previous sections, you do not need to download or manually install the package(s) below. This is only for the offline scenario.

  1. First, locate and copy the mssql-tools package for your Linux distribution:

    Linux distributionmssql-tools package location
    Red Hathttps://packages.microsoft.com/rhel/7.3/prod
    SLEShttps://packages.microsoft.com/sles/12/prod
    Ubuntu 16.04https://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/mssql-tools
  2. Also locate and copy the msodbcsql package, which is a dependency. The msodbcsql package also has a dependency on either unixODBC-devel (Red Hat and SLES) or unixodbc-dev (Ubuntu). The location of the msodbcsql packages are listed in the following table:

    Linux distributionODBC packages location
    Red Hathttps://packages.microsoft.com/rhel/7.3/prod
    SLEShttps://packages.microsoft.com/sles/12/prod
    Ubuntu 16.04msodbcsql
    unixodbc-dev
  3. 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.

  4. Install the and packages: Install the mssql-tools and msodbc packages. If you get any dependency errors, ignore them until the next step.

    PlatformPackage install commands
    Red Hatsudo yum localinstall msodbcsql-<version>.rpm
    sudo yum localinstall mssql-tools-<version>.rpm
    SLESsudo zypper install msodbcsql-<version>.rpm
    sudo zypper install mssql-tools-<version>.rpm
    Ubuntusudo dpkg -i msodbcsql_<version>.deb
    sudo dpkg -i mssql-tools_<version>.deb
  5. 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.

    For RPM packages, you can inspect the required dependencies with the following commands:

    For Debian packages, if you have access to approved repositories containing those dependencies, the easiest solution is to use the apt-get command:

    Note

    This command completes the installation of the SQL Server packages as well.

    If this does not work for your Debian package, you can inspect the required dependencies with the following commands:

Next steps

For an example of how to use sqlcmd to connect to SQL Server and create a database, see one of the following quickstarts:

Ubuntu Command Line Commands

For an example of how to use bcp to bulk import and export data, see Bulk copy data to SQL Server on Linux.