sqlcmd client Connection error to sqlserver on windows server
本文最后更新于:2024年8月9日 晚上
Case scenario
I installed SQL Server 2019
on Windows Server 2022
, When I successful installed SQL Server
, local connection with sql server management studio
all good. Well, when I tried to using sqlcmd
to connect the SQL Server
on another Linux machine.
I encountered an issue like this:
1 |
|
Troubleshooting
Check SQL server connection protocol
we know sqlcmd
use TCP/IP
communicating with the server , so I checked the the server side connection protocol, make sure TCP/IP
protocol enabled. Basically, It has been enabled by default. But we still need to make sure it has been enabled.
Check IPAddress and TCP Port 1433
why we check this?
Because on sql server TCP/IP
configuration parameter, there is an optional value called Dynamic TCP Port
, we have to disable it and set a static IP and port
.
Checked TCP 1433, Well, not listening. Further checking, Dynamic TCP Port
value set with 0
,that means enabled, we had to leave it blank to disable it. At meanwhile, We have to enable the IP just like below:
After Restarting
the SQL server
, check again:
Add firewall rules for SQL server(optional)
This step is optional, When you still have connection issues you can try this .