How to Install SQL Server on SUSE 12

This article provides step-by-step instructions for installing SQL Server 2019 for Linux on SUSE Linux Enterprise Server 12.

These steps should work on SUSE Linux Enterprise Server 12, SP2, SP3, SP4, and SP5.

You should have at least 2GB of memory before you install SQL Server on your SUSE machine. If you’re installing this on a virtual machine, you should have at least 2GB of memory allocated to it.

The file system must be XFS or EXT4.

Install SQL Server

The following steps will install SQL Server 2019 for Linux on SUSE Linux Enterprise Server 12.

Open terminal, and run the following commands.

Download the Microsoft SQL Server 2019 SLES repository configuration file:

sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/mssql-server-2019.repo

Refresh your repositories:

sudo zypper --gpg-auto-import-keys refresh

To ensure that the Microsoft package signing key is installed on your system, use the following command:

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

Install SQL Server:

sudo zypper install -y mssql-server

Run mssql-conf setup:

sudo /opt/mssql/bin/mssql-conf setup

Follow the prompts to choose your edition, accept the license agreement, and set the sa password.

Be sure to set a strong password (minimum length 8 characters, including uppercase and lowercase letters, base 10 digits and/or non-alphanumeric symbols).

Check the Status of SQL Server

You can run the following command to verify that SQL Server is running:

systemctl status mssql-server

Remote Connections

To allow remote connections, you’ll need to open the SQL Server port on the firewall.

SQL Server’s default port is TCP 1433.

If you are using the SuSE firewall, you need to edit the /etc/sysconfig/SuSEfirewall2 configuration file so that the FW_SERVICES_EXT_TCP entry specifies the SQL Server port number:

FW_SERVICES_EXT_TCP="1433"

Install Command-Line Tools

Now that you’ve installed SQL Server, you’ll need some sort of tool to connect to it.

The following steps will get you set up with two SQL Server command-line tools: sqlcmd and bcp.

Add the Microsoft SQL Server repository to Zypper:

sudo zypper addrepo -fc https://packages.microsoft.com/config/sles/12/prod.repo 
sudo zypper --gpg-auto-import-keys refresh

Now, install mssql-tools with the unixODBC developer package:

sudo zypper install -y mssql-tools unixODBC-devel

You’ll be prompted to accept the licence terms twice. If you agree with the terms, enter YES on both occassions.

Add to PATH

You can optionally add the  /opt/mssql-tools/bin/ to your PATH environment variable, so that you can run the tools without having to provide the full path.

To make sqlcmd/bcp accessible from the bash shell for login sessions:

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile

To make sqlcmd/bcp accessible from the bash shell for interactive/non-login sessions:

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

Connect to SQL Server

Now that SQL Server is installed, and the command-line tools are also installed, we can use the command-line tools to connect to SQL Server.

Enter the following, but replace <YourPassword> with your own password:

sqlcmd -S localhost -U SA -P '<YourPassword>'

Alternatively, you can omit -P '<YourPassword>' and you will be prompted for it instead.

To connect to a remote instance, change localhost to the machine name or IP address, and be sure to have port 1433 open on the firewall.

Once you’ve connected successfully, you should see a prompt that looks like this:

1>

From here, you can use T-SQL to create databases, run queries, and more.

For now, enter the following code to check your version of SQL Server:

SELECT @@version
GO

If you’re new to SQL Server, check out my SQL Server tutorial over at Quackit.