How to run SQL Server v.Next Public Preview on Fedora

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

For Developers Using Software

8 Comments

  1. Gary

    This is a part of Microsoft’s EEE strategy. Needing to remove a package that makes other database software unusable? Really?

    • @Gary: Actually, the only reason I could detect for this was a file conflict between the packages. Nothing sneaky or odd. I suspect the standard unixODBC has a different, maybe more limited, support for UTF16 characters required for the SQL Server.

  2. Moved from Windows long back as soon as I came across linux. Embraced it and its related technologies and software and contented with it. Wondering why would people from open source world require something from closed source world when the former has enough choices to opt from with freedom to see the source and quite stable from almost the start. I said closed source because I do not trust and believe Microsoft. Pay for services not for a buggy closed source product. This is my strong opinion and respecting others too with valid points 😉 .

  3. Gines

    No good install , why?

    root@MSSQL ~]# sudo systemctl status mssql-server mssql-server-telemetry
    ● mssql-server.service - Microsoft(R) SQL Server(R) Database Engine
       Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
       Active: inactive (dead) (Result: exit-code) since sáb 2016-11-19 22:42:56 CET; 38min ago
      Process: 758 ExecStart=/opt/mssql/bin/sqlservr (code=exited, status=127)
     Main PID: 758 (code=exited, status=127)

    nov 19 22:42:56 localhost.localdomain systemd[1]: mssql-server.service: Service hold-off time over, scheduling restart.
    nov 19 22:42:56 localhost.localdomain systemd[1]: Stopped Microsoft(R) SQL Server(R) Database Engine.
    nov 19 22:42:56 localhost.localdomain systemd[1]: mssql-server.service: Start request repeated too quickly.
    nov 19 22:42:56 localhost.localdomain systemd[1]: Failed to start Microsoft(R) SQL Server(R) Database Engine.

    ● mssql-server-telemetry.service - Microsoft(R) SQL Server(R) Telemetry Service
       Loaded: loaded (/usr/lib/systemd/system/mssql-server-telemetry.service; enabled; vendor preset: disabled)
       Active: inactive (dead) (Result: exit-code) since sáb 2016-11-19 22:42:55 CET; 38min ago
      Process: 754 ExecStart=/opt/mssql/bin/sqlservr-telemetry /var/opt/mssql/.system (code=exited, status=127)
     Main PID: 754 (code=exited, status=127)

    nov 19 22:42:55 localhost.localdomain systemd[1]: mssql-server-telemetry.service: Service hold-off time over, scheduling restart.
    nov 19 22:42:55 localhost.localdomain systemd[1]: Stopped Microsoft(R) SQL Server(R) Telemetry Service.
    nov 19 22:42:55 localhost.localdomain systemd[1]: mssql-server-telemetry.service: Start request repeated too quickly.
    nov 19 22:42:55 localhost.localdomain systemd[1]: Failed to start Microsoft(R) SQL Server(R) Telemetry Service.
    [root@MSSQL ~]#
  4. Ted Perez

    Hi all. i can’t seem to get mssql-server running. Here’s what i’m getting:

    [root@localhost ~]# uname -a
    Linux localhost.localdomain 4.8.8-300.fc25.x86_64 #1 SMP Tue Nov 15 18:10:06 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
    [root@localhost ~]# cat /etc/system-release
    Fedora release 25 (Twenty Five)
    [root@localhost ~]#
    [root@localhost ~]# systemctl status mssql-server
    ● mssql-server.service - Microsoft(R) SQL Server(R) Database Engine
       Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled; vendor preset: disabled)
       Active: failed (Result: start-limit-hit) since Sun 2016-11-20 14:06:24 PHT; 2min 30s ago
      Process: 1343 ExecStart=/opt/mssql/bin/sqlservr (code=exited, status=127)
     Main PID: 1343 (code=exited, status=127)

    Nov 20 14:06:24 localhost.localdomain systemd[1]: mssql-server.service: Main process exited, code=exited, status=127/n/a
    Nov 20 14:06:24 localhost.localdomain systemd[1]: mssql-server.service: Unit entered failed state.
    Nov 20 14:06:24 localhost.localdomain systemd[1]: mssql-server.service: Failed with result 'exit-code'.
    Nov 20 14:06:24 localhost.localdomain systemd[1]: mssql-server.service: Service hold-off time over, scheduling restart.
    Nov 20 14:06:24 localhost.localdomain systemd[1]: Stopped Microsoft(R) SQL Server(R) Database Engine.
    Nov 20 14:06:24 localhost.localdomain systemd[1]: mssql-server.service: Start request repeated too quickly.
    Nov 20 14:06:24 localhost.localdomain systemd[1]: Failed to start Microsoft(R) SQL Server(R) Database Engine.
    Nov 20 14:06:24 localhost.localdomain systemd[1]: mssql-server.service: Unit entered failed state.
    Nov 20 14:06:24 localhost.localdomain systemd[1]: mssql-server.service: Failed with result 'start-limit-hit'.
    [root@localhost ~]#

    Any ideas / suggestions? Thanks in advance

  5. john posey

    How does one install a guest virtual machine?

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions