No, this headline is not a joke! A decade ago, you probably wouldn’t think of Microsoft when you hear Linux or open source. Just this week, though, Microsoft introduced a public preview of one of their top products, SQL Server, for Linux. The SQL Server v.Next Public Preview is available for free download now. This article shows you how to run it on Fedora 25, which is due to release next week.

Of course, Fedora already offers several full-featured, free and open source relational SQL databases. Both mariadba recent fork of MySQL with active community development, and postgresql are popular worldwide. They’re known for ease of use, features, and stability. But SQL Server has many users as well. This is one more way those users can try new features using Fedora.

This process uses packages Microsoft provides for Red Hat Enterprise Linux 7. These packages seem to work fine so far in testing on Fedora 25 as well. However, it’s a preview release, so the usual caveats apply.

Note for existing database servers

To avoid any software conflict, you need to remove the unixODBC package Fedora provides by default. To remove unixODBC, run this command:

sudo dnf remove unixODBC

Be aware this package is required by some other database servers like mariadb. Maybe you don’t want to remove those database server packages, though. No problem — make a virtual guest machine, and run the rest of this process on the guest.

Installing SQL Server v.Next Public Preview

First install the repository definition files:

sudo su -
curl https://packages.microsoft.com/config/rhel/7/mssql-server.repo > /etc/yum.repos.d/mssql-server.repo
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
exit

Next, install the Microsoft SQL Server v.Next Public Preview packages using dnf:

sudo dnf -y install mssql-server mssql-tools

Open the default port on your firewall:

sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
sudo firewall-cmd --reload

Next, run the setup helper for SQL Server. This lets you add a system administrator (SA) password. Do not start the service when prompted.

sudo /opt/mssql/bin/sqlservr-setup

Finally, start the SQL Server service units using systemd:

sudo systemctl start mssql-server mssql-server-telemetry

Optionally, you can enable them for startup at boot time:

sudo systemctl enable mssql-server mssql-server-telemetry

Testing the installation

To test the server is working properly, use the tools installed earlier. The mssql-tools package provides the sqlcmd utility for connecting to the SQL Server. Use this command on the box where you installed both the server and tools:

sqlcmd -S localhost -U SA

You’ll need to provide the system administrator password you set up earlier.

A prompt 1> appears for you to send SQL commands to the server. Here is an example of a command to list the installed system databases. You need to enter both lines. The GO command tells the server to process the previous line.

SELECT Name from sys.Databases;
GO

You should see an output like this:

Name 
--------------------------------------------------------------------------------------------------------------------------------
master 
tempdb 
model 
msdb 

(4 rows affected)

To quit the sqlcmd session, enter the single command QUIT.

For more information on the SQL Server v.Next Public Preview for Linux, visit the official website.


Featured image contains Database icon by Nancy from the Noun Project