Over a million developers have joined DZone.

Repair SQL Server on Linux After an Ubuntu Distribution Upgrade [Snippet]

DZone 's Guide to

Repair SQL Server on Linux After an Ubuntu Distribution Upgrade [Snippet]

Let's look at this brief article, which includes an issue as well as a solution in the form of code.

· Database Zone ·
Free Resource

SQL Server 2017 is supported on Ubuntu 16.04 LTS (Long-Term Support), however that version of Ubuntu Linux is now more than two years old, so you may be tempted to update Ubuntu to a more modern release such as Ubuntu 18.04 LTS (Bionic Beaver). Unfortunately (as of this writing), SQL Server 2017 is not supported on later versions of Ubuntu.

(Note: Ubuntu releases new distributions every six months. The version number 16.04 means that it was released in April 2016.)

The more adventurous among us who use SQL Server 2017 in a development environment — where we need to keep the Ubuntu distribution as up to date as possible — might run into the following issue:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help resolve the situation:

The following packages have unmet dependencies:
mssql-server : Depends: openssl (<= 1.1.0)
E: Unable to correct problems, you have held broken packages.

I would like to share this very handy answer written by langioletto that I found on Ask Ubuntu, which resolves this dependency issue.

WARNING: Downgrading packages is dangerous, especially in libraries like OpenSSL.  Do not run this in a production environment!
apt-get install -y libjemalloc1 libsss-nss-idmap0 libc++1 gawk curl
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list)"
add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list)"
wget http://archive.ubuntu.com/ubuntu/pool/main/c/ca-certificates/ca-certificates_20160104ubuntu1_all.deb
dpkg -i ca-certificates_20160104ubuntu1_all.deb
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/openssl_1.0.2g-1ubuntu4_amd64.deb
dpkg -i openssl_1.0.2g-1ubuntu4_amd64.deb
apt install -y libcurl3
apt-get update
apt-get install -y mssql-server

Once SQL Server is installed, you will have to run sudo /opt/mssql/bin/mssql-conf setup to make sure SQL Server is configured correctly. Fortunately, SQL Server 2017 on Linux is non-destructive with any databases you already had from previous installations, so the service should start up happily by itself and all your databases should be usable.

Thanks, langioletto!

Share your Linux development environment tips and tricks with me on Twitter at @bornsql.

database ,sql server ,ubuntu ,linux

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}