DEV Community

Seffu Kioi Nyambura
Seffu Kioi Nyambura

Posted on

Install SQL Server command-line tools

After successful installation of SQL Server in ubuntu, we need a way to access it trough the terminal. This post illustrates steps you can take to make this possible

Prerequisites:

  • Account with sudo privileges
  • Successful installation of SQL Server in Ubuntu

Procedure:

Step 1: Open terminal
Use the shortcut Ctrl + alt + t to open the terminal
Step 2: Update and install curl (Optional)

sudo apt update && sudo apt install curl
Enter fullscreen mode Exit fullscreen mode

update
Step 3: Import the public repository GPG keys

curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
Enter fullscreen mode Exit fullscreen mode

import
Step 4: Register the Microsoft Ubuntu repository

curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
Enter fullscreen mode Exit fullscreen mode

register

Step 5: Update the sources list and install mssql-tools and odbc drivers

sudo apt update 
sudo apt install mssql-tools unixodbc-dev
Enter fullscreen mode Exit fullscreen mode

installdrivers
Step 6: Add mssql-tools to your PATH environment variable

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

addtopath
Step 7: Connect local
Replace 'YourPassword' with the password you set during installation

sqlcmd -S localhost -U SA -P '<YourPassword>'
Enter fullscreen mode Exit fullscreen mode

Congratulations you can now access mssql server in ubuntu

Top comments (0)