10

I'm new to WSL, and running Ubuntu. I have a local instance of SQL Server 2017 installed in Windows, and want to connect to it from WSL. I have remote connections enabled, however, I can't seem to get connected from ubuntu locally.

I installed the db tools for ubuntu, and I'm using sqlcmd:

sqlcmd -S localhost -U sa -P <my password>

This keeps failing. How do I format/configure this to allow SQL Server in Windows to be available to Ubuntu?

Thanks!

EDIT

I'm using the default instance of SQL Server

Here's the error I'm getting

Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2749.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

Pinging localhost:

$ ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=128 time=0.248 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=128 time=0.497 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=128 time=0.517 ms
TheTFo
  • 741
  • 2
  • 8
  • 25
  • What does "keeps failing" mean? What error message(s) do you get? – alroc Feb 22 '19 at 01:22
  • Can you ping localhost from Ubuntu? Is your server a default instance or a named instance? – squillman Feb 22 '19 at 03:36
  • Thanks for responding, sorry I left that info out. I edited my post with the error, as well as ping results. I'm using the default instance – TheTFo Feb 22 '19 at 15:19

2 Answers2

10
  1. Launch SQL Server Configuration Manager
  2. Click on SQL Server Network Configuration
  3. Right click on TCP/IP and click "Enable"
  4. Go to your Services and Restart SQL Server

Screenshot from Sql Server Configuration Manager

Sameer Alibhai
  • 3,092
  • 4
  • 36
  • 36
TheTFo
  • 741
  • 2
  • 8
  • 25
9

The solution provided by TheTFo for me did not fully work. I had to take it a step further by ensuring that the appropriate IP Address was enabled as well. Refer to Step 6 of this resource for instructions on how to do so.

Matt Wohler
  • 151
  • 1
  • 6