Install SQL Server command-line tools

seffu

Seffu Kioi Nyambura

Posted on April 26, 2022

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

💖 💪 🙅 🚩
seffu
Seffu Kioi Nyambura

Posted on April 26, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related