Ubuntu 20.04 Cannot Connect To SQL Server Error Code 0x2746
After installing SQL Server command line tools on Ubuntu 20.04, I still cannot connect to MS SQL Server.
I got this following error while executing the command
dolly@ubuntu:~$ sqlcmd -S <ms-sql-server> -U SA -P '<password>'Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2746.
After search solutions for this problem, I got this
Based on that answer, this was problem between Openssl and SQL Server protocol/version. And there were two solutions for this problem
- Change OpenSSL Security Level, or
- Update Openssl Version
Change OpenSSL Security Level in Ubuntu 20.04
Ubuntu 20.04 use Security Level 2 by default. And SQL Server protocol required Security Level 1. You can follow this to change the Security Level
https://askubuntu.com/questions/1233186/ubuntu-20-04-how-to-set-lower-ssl-security-level
Update/Downgrade Openssl Version
Ubuntu 20.04 use Openssl version 1.1.1f by default. SQL Server protocol worked well with Openssl Version 1.1.0. But you don’t need to downgrade the Openssl version, you can update the Openssl version to 1.1.1k. Just follow this to tutorial
Sometimes we get error without let us know the actual problem. I write his post to help people who want to know what is the actual problem and the solution for this error. And I hope this post can save your time!