Fix That SQL Server 2019 Error on Ubuntu 18.04

Jim Kang
Jim Kang
Dec 2, 2019 · 1 min read

So you’ve followed along the docs to install MSSQL server 2019 on ubuntu 18.04 and you’ve encountered the following error:

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2746.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Client unable to establish connection.

well, let’s get that fixed right away!

Reason Why it’s Not Working

TL;DR; SQL Server 2017/2019 have a dependency on OpenSSL v1.0, while Ubuntu 18.04 comes with v1.1

Step 1 — Stop SQL Server

sudo systemctl stop mssql-server

Step 2 — Configuration

sudo systemctl edit mssql-server

then add the following line

[Service]
Environment="LD_LIBRARY_PATH=/opt/mssql/lib"

save and exit

Step 3 — Link OpenSSL

sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /opt/mssql/lib/libssl.sosudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /opt/mssql/lib/libcrypto.so

Step 4-Start SQL Server

sudo systemctl start mssql-server

Now you should be able to login using

sqlcmd -S 127.0.0.1 -U SA
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade