# **MSSQL 遠端連線管理** ## **1. 防火牆設定** :::warning Enable TCP port 1433 (default port for SQL Server) ::: :::success 以管理員身份開啟 Windows PowerShell ![](https://i.imgur.com/iDHvcdF.png) <br> 輸入下列指令 ``` New-NetFirewallRule -DisplayName "SQLServer default instance" -Direction Inbound -LocalPort 1433 -Protocol TCP -Action Allow New-NetFirewallRule -DisplayName "SQLServer Browser service" -Direction Inbound -LocalPort 1434 -Protocol UDP -Action Allow ``` ![](https://i.imgur.com/HQ4J2sz.png) ::: ## **2. SQL Server 設置** :::success ### **設置認證及登入模式** **執行 SSMS -> 指定 Instance Properties -> Security ** ![](https://i.imgur.com/RwCRmEo.png) <br> ![](https://i.imgur.com/d2L2eiH.png) 勾選 SQL Server and Windows Authentication mode <br> **移至 Connections page** ![](https://i.imgur.com/mXisyxH.png) 勾選 Allow remote connectios to this server ::: ## **3. 設置 Listen 服務** :::success **執行 SQL Server Confituration Manager** ![](https://i.imgur.com/G1GPY4Z.png) <br> SQL Server Netowrk Configuration -> Protocols -> TCP/IP -> Enable ![](https://i.imgur.com/Kl7EKMJ.png) <br> SQL Server Services -> SQL Server -> Restart ![](https://i.imgur.com/MZ73ddK.png) <br> 以 SSMS 改以 IP 方式連接 ![](https://i.imgur.com/zRfBizp.png) ::: ###### tags: `Database` `MSSQL`