TransWikia.com

Can not connect to SQL Server from Ubuntu sqlcmd client

Database Administrators Asked by CarlosRPEvertsz on November 17, 2021

I’m trying to connect to a SQL Server Express server from a Linux Ubuntu 16.04 computer. I Installed all SQL commad line utilities for the linux machine and follow instructions from Microsoft SQL Server on Linux docs.

When I run

sqlcmd -S ip/SQLEXPRESS -U SA -P 1234

the command always returns the following error :

Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x2AF9

I was able to run the same command from a Windows 10 computers and it works with no flaws.

The linux computer can communicate to the server machine and SQL Server 1433 port. I test this with the linux nc command (netcat).

Linux nc command results:

nc -z -v -w5 192.168.0.1 1433

Connection to 192.168.0.1 1433 port [tcp/ms-sql-s] succeeded!

Any suggestions or something missing?

I have tried changing the ports, parameter order etc… and Linux version of sqlcmd doesn’t work.

I also tried including extra ‘/’ character, because it is special on Linux. The new command line is sqlcmd -S ip//SQLEXPRESS -U SA -P 1234 but it doesn’t work. It works faster but returns other error:

Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x2746.

Instance name doesn’t work neither. sqlcmd -S SERVER-NAME\SQLEXPRESS -U SA -P 1234 or sqlcmd -H ipaddress -S SERVER-NAME\SQLEXPRESS -U SA -P 1234 The command recognizes quotes so sqlcmd -S "SERVER-NAMESQLEXPRESS" -U SA -P 1234. Nothing works.

The correct syntax is sqlcmd -S ip\SQLEXPRESS -U SA -P 1234 with double ”. It doesn’t connect anyway. I have several days struggling with it and could not find a way to make this thing work.

One Answer

I think the right command should be:

sqlcmd -S <IP>\SQLEXPRESS,1433 -U SA 

Answered by Francesco Mantovani on November 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP