A post on installing SQL Server on Linux, following the Microsoft SQL Server 2019 Guide (Red Hat).
# Install SQL Server.
# Install the SQL Server Command-Line Tools.
# Connect to SQL Server Locally.
# Connect to SQL Server Remotely.
Install SQL Server
1. Get connected & download the Microsoft SQL Server 2019 Red Hat repository configuration file.
sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/8/mssql-server-2019.repo
2. Install SQL Server.
sudo yum install -y mssql-server
3. Run mssql-conf setup to choose the SQL Server Edition, SA password and accepting of the Licence Agreement.
sudo /opt/mssql/bin/mssql-conf setup
4. Check the SQL Server service by running systemctl status.
systemctl status mssql-server
5. Allow in remote 1433 connections.
I’m using Firewalld as per Microsoft’s guide – here’s my quick install notes.
sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent sudo firewall-cmd --reload
Install the SQL Server Command-Line Tools
1. Download the Microsoft Red Hat repo config file.
sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo
2. Install ODBC driver for SQL Server (Linux) – allows BCP & SQLCMD.
sudo yum install -y mssql-tools unixODBC-devel
3. Add mssql-tools to PATH environment variable – allows tools to be run without full path.
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc source ~/.bashrc
Connect to SQL Server Locally
Using the PATH variable above, call sqlcmd:
Connect to SQL Server Remotely
I’m connecting to the EC2 Amazon Linux SQL Server instance via SSMS on my local machine (Windows 10).
For this to work we had to allow in remote 1433 connections (step 5 during install above), and I added my IP into the AWS Security Group.
Leave a Reply