我目前正在學習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 –
具有相同的問題,仍然沒有回答 –