SQL server Linux and SQLCMD

Following on from a previous blog post (https://blobeater.blog/2021/01/15/sql-server-linux/) on installing SQL Linux, a common requirement will be the need to connect to it to issue queries, typically via SQLCMD). There isn’t too much to it but still an important step.

This example was for my Red Hat variant.

Enter super user

sudo su

Download the Microsoft Red Hat repository configuration file.

curl https://packages.microsoft.com/config/rhel/8/prod.repo > /etc/yum.repos.d/msprod.repo

Exit super user

exit

Install mssql-tools with the unixODBC developer package

sudo yum install mssql-tools unixODBC-devel

A little thing here, if you used an Azure VM that has a linux image of SQL already installed you will need to change sa password to connect.

sudo systemctl stop mssql-server

sudo /opt/mssql/bin/mssql-conf set-sa-password

Then you can issue SQL commands.