我目前正在学习SQL Server,并且在使用sqlcmd
连接到本地数据库时遇到问题。无法通过sqlcmd连接到LocalDB
当我在下面到PowerShell的类型:
sqlcmd -S "(localdb)\mssqllocaldb"
我收到以下错误信息:
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : SQL Server Network Interfaces: The system cannot find the file specified.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 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.
我可以连接到本地数据库,如果我使用SQL Server Management Studio中。如果我使用实例名称管道,我也可以连接到本地数据库。
我有一个干净的安装Windows 10 64,Visual Studio的社区,和SQL Server Management Studio中2016年
是'(的LocalDB)'你的主机名和'mssqllocaldb'数据库实例的名称?你[启用TCP协议](https://technet.microsoft.com/en-us/library/hh231672%28v=sql.110%29.aspx)? [参考文献](https://msdn.microsoft.com/de-ch/library/ms188247.aspx)。 –
使用'Invoke-Sqlcmd'为我解决了这个问题。在这里回答的建议:http://stackoverflow.com/questions/34457048/trouble-connecting-to-localdb-via-sqlcmd-in-powershell-what-is-server-instance –
具有相同的问题,仍然没有回答 –