初步嘗試
我有一個Azure的VM與Windows Server 2012中,關於這一點我剛剛安裝了SQL Server 2012 Express數據庫引擎零件。然後,我按照指示here遠程連接到SQL Server Management Studio。使用SQL Server Management Studio中遠程連接到託管在Azure中虛擬機的SQL Server Express實例
- Create a TCP endpoint for the virtual machine
- Open TCP ports in the Windows firewall
- Configure SQL Server to listen on the TCP protocol
- Configure SQL Server for mixed mode authentication
- Create SQL Server authentication logins
- Determine the DNS name of the virtual machine
- Connect to the Database Engine from another computer
第七步後,我收到以下錯誤:
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)
還有什麼我需要遠程連接之前配置?
故障排除
我一直在下面的故障排除說明here。下面的每個blockquote是描述該鏈接的步驟。
Confirm the instance of the SQL Server Database Engine is installed and running.
完成。我們安裝了SQL Server Express,並且它作爲名爲SQLEXPRESS的命名實例運行。
If you are attempting to connect to a named instance, make sure the SQL Server Browser service is running.
完成。我們按照步驟here打開SQL Server Browser服務。
Get the IP Address of the computer.
完成。我們稍後將使用這些測試來測試連通性,並可能爲SQLEXPRESS設置一個靜態端口。
10.241.62.155
FE80 :: 45:8c29:e19f:f78b%15
Get the TCP port number used by SQL Server.
完成。該SQL Server Management Studio服務器日誌顯示服務器正在偵聽端口49169.
Enable Protocols
完成。我們已經在配置管理器中啓用了TCP/IP,但爲了以防萬一,我們重新啓動了SQL Server服務。
Testing TCP/IP Connectivity
完成。我們使用tcping.exe來測試連接(CMD ping不與天青迅速開展工作。)我們能夠連接到端口80
- tcping.exe buddha.cloudapp.net>成功
- tcping.exe佛.cloudapp.net 80>成功
Testing a Local Connection
完成。我們在命令提示符下使用了sqlcmd.exe,並且能夠通過TCP以本地方式連接用戶名和密碼。
- SQLCMD -S佛\ SQLEXPRESS(經由共享存儲器協議成功)
- SQLCMD -S TCP:佛\ SQLEXPRESS(經由TCP成功)
- SQLCMD -S TCP:佛\ SQLEXPRESS -U SA - P(通過TCP成功與用戶名)
- 的sqlcmd -S TCP:10.241.62.155 \ SQLEXPRESS -U SA P(內部IP成功)
Opening a Port in the Firewall
我們打開了我們SQL端口EXPRESS收聽。服務器日誌(上圖)顯示,SQLEXPRESS是偵聽端口49169,但是這僅僅是衆多動態端口之一,我們希望建立靜態端口1435
- 使用WF.msc創建入站端口TCP規則1435
- 使用Azure管理門戶創建TCP端點端口1435
的故障排除指導也說:
If you are connecting to a named instance or a port other than TCP port 1433, you must also open the UDP port 1434 for the SQL Server Browser service.
由於w^e正在連接SQLEXPRESS(一個命名實例),我們需要爲UDP打開端口1434。
- 使用WF.msc爲端口創建入站UCP規則1434
- 使用Azure管理門戶創建UDP端點端口1434
進一步研究有關連接到命名實例揭示了動態端口問題。爲什麼我們要使用端口1435(靜態),而不是端口49169的原因(許多有效的辦法之一。)
Instances of SQL Server Express, SQL Server Compact, and named instances of the Database Engine use dynamic ports. To configure these instances to use a specific port, see Configure a Server to Listen on a Specific TCP Port (SQL Server Configuration Manager). and here .
完成。我們進入SQL配置管理器> SQL Server網絡配置> SQLEXPRESS> TCP/IP協議,我們做了以下工作。
協議選項卡>全部收聽>否。
IP地址選項卡>列出的每個地址
- 啓用>是
- TCP動態端口>空白(刪除零)
- TCP端口> 1435(或您選擇)
重新啓動SQLEXPRESS服務後,我們再次查看了SQL Server Management Studio日誌,發現服務器正在偵聽端口1435!萬歲!
Testing the Connection
完成。我們在本地(非Azure)計算機上打開SQL Server Management Studio並連接。
- buddha.cloudapp.net,1435或buddha.cloudapp。NET \ SQLEXPRESS
- SA
- 密碼
成功。
哇,列出所有步驟和嘗試的令人難以置信的工作。 – 2014-05-04 01:51:15
你剛剛爲我節省了很多時間!對我來說最重要的是協議選項卡>全部收聽>無。我不必從1433改變IP,但是我確實從動態端口中刪除了0來獲得更好的效果。我假設我的問題源自所有其他列出的協議正在偵聽。做得好! – hiro77 2014-09-05 19:25:43