问题
I'm attempting to connect to a test Database on a Parallels VM on Mac using Azure Data Studio, but I'm getting the standard, generic connection error:
System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)
Steps I've taken so far to open the connection include:
- Opening port 1433 through windows firewall
- Ensuring remote connections are allowed on the SQL instance
- Setting the TCP/IP Protocol to 5171 for IPAll
- Running SQL Server and SQL Browser Instances
- Adding a rule to windows firewall for sqlservr.exe to allow all connections
- Enabling the SA account and adding a password (password is correct - I've double checked in SSMS on the VM)
I'm able to connect from the windows VM but not the Mac.
My connection string is below (IP is correct, again I've double checked):
Is there a step I've missed or some extra config that I need to do on the VM itself maybe? Or maybe the connection string isn't quite right? I've also tried using the Machine Alias to connect to the instance (SQLEXPRESS) - but still no joy. Anyone know what the problem might be because it's driving me crazy and I can see that other devs have made it work, so I know it's possible. My version of Parallels is Desktop 15, I don't know if that makes a difference or not?
回答1:
Ok so turns out I needed to open the IPAll port I had set for the TCP/IP Config which in my case was 5171 as well as adding a rule to allow SQL Server Browser to connect to the internet.
来源:https://stackoverflow.com/questions/59472554/how-to-connect-to-an-sql-server-on-parallels-vm