How do I install MS SQL for ubuntu 18.04 LTS?

I looked up on the internet but all those steps to install were regarding 16.04 version. Is it available yet on 18.04 ? If yes,how?


Solution 1:

Microsoft does not provide official mssql-server for 18.04 yet (05-12-2018), for testing only you may try this workaround(from me).

Workaround for installing Microsoft's SQL Server (mssql) on Ubuntu

WARNING: FOR TESTING ONLY

  1. Download latest package mssql-server_14.0.3025.34-3_amd64.deb from https://packages.microsoft.com/ubuntu/16.04/mssql-server-2017/pool/main/m/mssql-server/

  2. Change directories

    cd ${HOME} && mkdir -p tmp/mssql/newpkg/DEBIAN/ && cd tmp/mssql
    wget https://packages.microsoft.com/ubuntu/16.04/mssql-server-2017/pool/main/m/mssql-server/mssql-server_14.0.3025.34-3_amd64.deb
    
  3. Unpack

    dpkg-deb -x mssql-server_14.0.3025.34-3_amd64.deb newpkg/
    dpkg-deb -e mssql-server_14.0.3025.34-3_amd64.deb newpkg/DEBIAN/
    
  4. Modify

    sed -i -e 's#openssl (<= 1.1.0)#openssl (<= 1.1.1)#g' newpkg/DEBIAN/control
    cat newpkg/DEBIAN/control | grep openssl
    
  5. Repackage

    dpkg-deb -b newpkg/ 18.04-mssql-server_14.0.3025.34-3_amd64_.deb
    
  6. First try, this will fail for dependencies

    sudo dpkg -i 18.04-mssql-server_14.0.3025.34-3_amd64_.deb
    
  7. Install dependencies

    sudo apt install -f
    
  8. Second try, this should be done

    sudo dpkg -i 18.04-mssql-server_14.0.3025.34-3_amd64_.deb
    
  9. Follow the messages from package to setup the mssql server

Troubleshooting

The database directory /var/opt/mssql should not put on zfs dataset, if you are using zfs, create a zvol and format as ext4/xfs for it.

Error: "Dump collecting thread [4404] hit exception [6]. Exiting."
Fix: sudo usermod -a -G disk mssql
Reason: mssql user can not access zvol.

References:

  • https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-linux-2017
  • https://gist.github.com/shamil/3140558

Solution 2:

So, the versions of ca-certificates and openssl provided by Ubuntu 18.04 actually work fine for mssql-server. Presumably it's rejecting openssh because 18.04's version of 1.1.0g-2ubuntu4 is technically 'higher' than mssql-server's demanded <=1.1.0 (and I would think they should have used <1.1.1 since that still locks you to a 1.1.0 variant while allowing for distribution-specific package versions which are something you should absolutely expect to run into but that's neither here nor there.)

The Fix

  1. Install dependencies
    sudo apt-get install libunwind8 libnuma1 libc6 adduser libjemalloc1 libc++1 gdb debconf libcurl3 hostname openssl python libgssapi-krb5-2 libsss-nss-idmap0 gawk sed
    (I fully realize you probably have most of these already installed, these are just all of the claimed dependencies.)
  2. Download the package
    apt-get download mssql-server
  3. Force installation
    sudo dpkg --force-depends -i mssql-server_14.0.3025.34-3.deb
  4. Remove downloaded .deb file
    rm mssql-server_14.0.3025.34-3_amd64.deb
  5. At this point, running any apt command will cause it to (harmlessly) complain that mssql-server has unmet dependencies and instruct you to run: sudo apt --fix-broken install
    DO NOT DO THIS. YOU WILL LOSE EVERYTHING YOU JUST DID.

    If you really want that error to go away, proceed with step 5, otherwise just ignore it and you're done.

  6. Convince dpkg that everything is okay
    1. sudo nano /var/lib/dpkg/status
       Your preferred editor is okay too
    2. Find the entry for mssql-server (for nano it's Ctrl-W, not Ctrl-F)
    3. Change the depends line from

      ...hostname, openssl (>= 1.0.1), openssl (<= 1.1.0), python (&lt= 2.7.0)...

      to

      ...hostname, openssl (>= 1.0.1), openssl (< 1.1.1), python (&lt= 2.7.0)...

If you forcibly installed the old versions of ca-certificates and openssl to get mssql-server to install, you can forcibly upgrade them by apt-get install ca-certificates openssl. This will remove mssql-server (but your configuration and databases should be left alone). Then you can follow my instructions.

This should avoid you having to deal with the hassle of repackaging things. You are trading that for playing tricks on dpkg but doing it this way will probably (I admit this is based on no research) make it easier to upgrade when an official 18.04 package comes out since you avoid creating and using an unofficial package and upgrading to an official package would clean up the changes we made automatically.

Solution 3:

Microsoft has updated SQL Server 2017 for Linux and now it can be installed in Ubuntu 18.04 but They are recommending for development only.

For more information check out the following Microsoft blog post: Installing SQL Server 2017 for Linux on Ubuntu 18.04 LTS

Solution 4:

Micrsoft's SQL website was last updated in April 2018 and shows Ubuntu 16.04 as the most currently supported version. I would wait until July 26, 2018 when Ubuntu 18.04.1 LTS is released to expect support from Microsoft.

Instead of paying for Microsoft's SQL you could try the free version of MySQL which supports Ubuntu 18.04 already.