2017-09-23 118 views
0

我试图通过安装了mssql扩展的Visual Studio代码连接到MSSQL。我也拉和运行与码头工人SQL服务器2017年集装箱形象,我试图做一个连接,虽然我得到一个错误:无法通过VSC与Docker连接到MSSQL(MacOS)

mssql: Failed to connect: 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: 25 - Connection string is not valid) ---> System.Net.Sockets.SocketException (0x80004005): Undefined error: 0 at System.Data.SqlClient.SN

图像正在运行的容器 - 我没有登录通过终端MSSQL,但我不能使用Visual Studio代码。我是否也必须提供一个实例?我在哪里可以找到它 - 在码头检查声明中无法找到它。

你们是否有类似的问题,也许找到了解决办法?

+0

你可以分享你的连接字符串 – TheGameiswar

+0

请分享连接字符串,你也怎样运行的SQL容器,请分享完整的命令 –

+0

我用下面的COMAND运行SQL容器 docker run -e'ACCEPT_EULA = Y'-e'MSSQL_SA_PASSWORD = '-p 1433:1433 --name sqlcontainer1 -d microsoft/mssql-server-linux 对于连接,我尝试使用localhost和内部IP的主机,但仍然没有什么 Server = localhost; User Id = SA; Password = MyPass; –

回答

1

好吧,我设法解决了这个问题。我连接到1401端口上的sql server容器(本地主机,VSC上的1401),但显然当您启动一个容器时,您需要更改sa的密码。新手的错误:)感谢试图帮助