<img src="https://miro.medium.com/max/1400/1*18lrHvJ8YtADJDT7hxIThA.jpeg" class="ge n o gd ab" width="700" height="553"/>

Problem in hand

So you have a VM or a remote server, that you have installed SQL Server, but you also want to connect to SQL Server using SQL Server Management Studio on your local system, but gives you this error.

This is because you haven’t configured it to allows inbound connections from firewall or from SQL Server itself, could be both.

Prerequisites

  1. Remote server/VM must have SQL Server Management Studio and SQL Server Configuration Manager Installed.
  2. Remote SQL Server must have a user that have read and write privileges (Here I’m using sa user)

All set, let’s start

Connect to the server/VM using Remote Desktop Connection and open up SQL Server Management Stdio on remote server, then connect to the SQL Server instance.

<img src="https://miro.medium.com/max/1400/1*ruDlsPJeSGTDk7pDBaM7Hw.jpeg" class="ge n o gd ab" width="700" height="394"/>

Connect to SQL Server instance from remote server.

<img src="https://miro.medium.com/max/892/1*0v10_MB-4tlE3sgO28RfCA.jpeg" class="ge n o gd ab" width="446" height="501"/>

Go to server properties.

Now right click on the server and go to Properties.

<img src="https://miro.medium.com/max/1378/1*yUx2BK492C1HnanRCyemPQ.jpeg" class="ge n o gd ab" width="689" height="625"/>

On the Connections page under Remote server connections, make sure that the Allow remote connections to this server is checked.

<img src="https://miro.medium.com/max/1270/1*TW0Of_vNs-tVyAZxQwhc1Q.jpeg" class="ge n o gd ab" width="635" height="635"/>

Now open SQL Server Configuration Manager.

<img src="https://miro.medium.com/max/1164/1*bZCvhiRUMqj99ZenptRITA.jpeg" class="ge n o gd ab" width="582" height="268"/>

Visit Protocols for <instance name>, in my case Protocols for MSSQLSERVER under SQL Server Network Configuration node, go to TCP/IP and make sure the ‘Status’ is set to Enabled. If not, right click and select Enable.

<img src="https://miro.medium.com/max/1238/1*9LrrYcU6ufwT1J5pgj-L-Q.jpeg" class="ge n o gd ab" width="619" height="353"/>
 

<img src="https://miro.medium.com/max/1174/1*e4MOVOGwNWMMp6I8dqAlCA.jpeg" class="ge n o gd ab" width="587" height="362"/>

After that, again right click and select Properties of TCP/IP protocol.

<img src="https://miro.medium.com/max/824/1*JvIellVWjttA5hHa2V9uVw.jpeg" class="ge n o gd ab" width="412" height="473"/>

Goto IP Addresses tab and go down until you see IPALL section. Make sure the TCP Port is set to 1433. If not set it to 1433.

<img src="https://miro.medium.com/max/964/1*fvu90GTkPhnAOxuVUiSbBg.jpeg" class="ge n o gd ab" width="482" height="164"/>

This warning will appear, so we need to restart the server. we can do it by using SQL Server Configuration manager.

<img src="https://miro.medium.com/max/1400/1*RCkiN4lzvBTTiYixjDVF9A.jpeg" class="ge n o gd ab" width="700" height="315"/>

Locate SQL Server under SQL Server Services, right click and select Restart.

Now lets configure the firewall.

 

<img src="https://miro.medium.com/max/786/1*Eu26_9BcTkA851nvnT1ULw.jpeg" class="ge n o gd ab" width="393" height="640"/>

Open up Windows Firewall.

<img src="https://miro.medium.com/max/1400/1*OoGUQcvnAN6UNoM5QR9MqA.jpeg" class="ge n o gd ab" width="700" height="450"/>

Go to Inbound Rules and select New Rule.

Add the following rule. Follow images if unclear.

Rule Type: Port

Protocol and Ports: TCP, 1433

Action: Allow the connection

Profile: Domain, Private, Public

Name: SQLTCP1433

<img src="https://miro.medium.com/max/1400/1*SC7gG6jqyQov8v-EBNQ_MA.jpeg" class="ge n o gd ab" width="700" height="570"/>

Click finish. We need to add another rule for UDP connections as well.

Rule Type: Port

Protocol and Ports: UDP, 1434

Action: Allow the connection

Profile: Domain, Private, Public

Name: SQLUDP1434

<img src="https://miro.medium.com/max/1400/1*wIqqXIQR3x-5M-qrWaNQVg.jpeg" class="ge n o gd ab" width="700" height="571"/>

Let’ make SQL Server and SQL Server Browser accessible through firewall.

Rule Type: Program

Program: C:\Program Files\Microsoft SQL Server\<Server version>.<Instance name>\MSSQL\Binn\sqlservr.exe

e.g. C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Binn

Action: Allow the connection

Profile: Domain, Private, Public

Name: SQLSERVER

<img src="https://miro.medium.com/max/978/1*EzYoTre_NC6_GgWgTtl4fg.jpeg" class="ge n o gd ab" width="489" height="246"/>

One more rule for the SQL Server Browser.

Rule Type: Program

Program: C:\Program Files (x86)\Microsoft SQL Server\90\Shared\sqlbrowser.exe

Action: Allow the connection

Profile: Domain, Private, Public

Name: SQLBROWSER

<img src="https://miro.medium.com/max/974/1*W8CGEp_f0wdMSQrBtTXI_A.jpeg" class="ge n o gd ab" width="487" height="230"/>

Now all four rules are setup.

<img src="https://miro.medium.com/max/1340/1*Nv3-cfcE7UE7q43dYI0-cA.jpeg" class="ge n o gd ab" width="670" height="208"/>

Make sure the SQL Server Browser and SQL Server is set to start automatically. Go back to SQL Server Configuration Manager and right click on SQL Server Browser under SQL Server Services, click Properties.

<img src="https://miro.medium.com/max/1240/1*XWolZOGQEAyFiYHtTDRIEg.jpeg" class="ge n o gd ab" width="620" height="304"/>

Under Service tab, select Automatic for Start mode.

<img src="https://miro.medium.com/max/828/1*s037cncXvmNMpMvMzyojYQ.jpeg" class="ge n o gd ab" width="414" height="475"/>

Click Apply. Now let’s make sure that we keep the service failures to minimum.

  1. Click the Windows key + R to open the Run window.
  2. Type services.msc in the Open: box.
  3. Click OK.
<img src="https://miro.medium.com/max/1400/1*bvILU6p0juJa7-ZcXng-6g.jpeg" class="ge n o gd ab" width="700" height="325"/>

Find the SQL Server service, right click and select Properties.

<img src="https://miro.medium.com/max/810/1*xWzgRZcBiQ93qoXNqAc3ig.jpeg" class="ge n o gd ab" width="405" height="467"/>

On the Recovery tab select Restart the Service for First failure, Second failure, Subsequent failures.

and Done!.

Try again to connect.

<img src="https://miro.medium.com/max/718/1*L2xBPov_1qKCQTm5OFFwKg.jpeg" class="ge n o gd ab" width="359" height="308"/>

Awesome! You did it. :)

How to enable remote connections to SQL Server的更多相关文章

  1. SQL: enable sa Account in SQL Server

    Link: http://sudeeptaganguly.wordpress.com/2010/04/20/how-to-enable-sa-account-in-sql-server/ 引用: Wh ...

  2. Enable a SQL Server Trace Flag Globally on Linux

    https://www.mssqltips.com/sql-server-tip-category/226/sql-server-on-linux// Microsoft has recently r ...

  3. System.Data.SqlClient.SqlException: 在与 SQL Server 建立连接时出现与网络相关的或特定于实例的错误。未找到或无法访问服务器。请验证实例名称是否正确并且 SQL Server 已配置为允许远程连接。 (provider: SQL Network Interfaces, error: 26 - 定位指定的服务器/实例时出错)

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. ...

  4. 【SQL Server 问题记录】A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.

    本文涉及的相关问题,如果你的问题或需求有与下面所述相似之处,请阅读本文 A network-related or instance-specific error occurred while esta ...

  5. Microsoft SQL Server Trace Flags

    Complete list of Microsoft SQL Server trace flags (585 trace flags) REMEMBER: Be extremely careful w ...

  6. Microsoft SQL Server Version List [sqlserver 7.0-------sql server 2016]

    http://sqlserverbuilds.blogspot.jp/   What version of SQL Server do I have? This unofficial build ch ...

  7. Microsoft SQL Server Version List(SQL Server 版本)

    原帖地址 What version of SQL Server do I have? This unofficial build chart lists all of the known Servic ...

  8. [MS SQL Server]SQL Server如何开启远程访问

    在日常工作中,经常需要连接到远程的MS SQL Server数据库中.当然也经常会出现下面的连接错误. 解决方法: 1. 设置数据库允许远程连接,数据库实例名-->右键--->属性---C ...

  9. 解决SQL Server管理器无法连接远程数据库Error: 1326错误

    解决SQL Server管理器无法连接远程数据库Error: 1326错误 我们在在使用SQL Server时都会遇到使用SQL Server Management Studio无法连接远程数据库实例 ...

随机推荐

  1. maven坐标及依赖范围的学习(1)

    首先,我们先了解什么是maven的坐标(重中之重): 在这里我们可以看到那三个红色的行,基本是pom.xml中出现的最多的配置     例如这个配置:这里我们可以看到我们这个项目的pom文件中,他对名 ...

  2. 初始html5

    一.html5的发展历史: 2004年提出构想:2008年发布第一份草案:2012年前后位推广阶段:2020年最终测试:2022年正式发布. 二.html5新特性: (1)html5 语义化更好: 新 ...

  3. C#计算两个时间年份月份天数(根据生日计算年龄)差,求时间间隔

    C#计算两个时间年份月份差 DateTime dt1 = Convert.ToDateTime("2008-8-8"); DateTime dt2 = System.DateTim ...

  4. Winform运行外部控制台程序,并在程序结束后执行其他动作

    ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = @"程序名"; psi.Arguments = @&qu ...

  5. 对于ssh服务的简单配置,似的自己的服务器更加安全

    对于一台服务器,最大的问题莫过于安全.没有安全性的服务器即使再牛*,性能再好,作用再大,也是分分钟被人搞定,而且还是揉虐性的...当然万事没有绝对的安全,我们只是将危险降低而已.本文只针对于ssh服务 ...

  6. 2.使用kubeadm快速搭建k8s集群

    准备工作: 时间同步 systemctl stop iptables.servicesystemctl stop firewalld.service 安装docker wget https://mir ...

  7. ES6拓展符修改对象

    // ES6 拓展符合并两个对象let ab = { ...a, ...b }; // 等同于 let ab = Object.assign({}, a, b); // 修改对象部分属性.用户自定义的 ...

  8. memcached-slab内存管理

    一.Memcache内存分配机制 关于这个机制网上有很多解释的,我个人的总结如下. Page为内存分配的最小单位. Memcached 的内存分配以page为单位,默认情况下一个page是1M,可以通 ...

  9. 纹理特征描述之灰度差分统计特征(平均值 对比度 熵) 计算和比较两幅纹理图像的灰度差分统计特征 matlab代码实现

    灰度差分统计特征有: 平均值:​ 对比度:​ 熵:​ i表示某一灰度值,p(i)表示图像取这一灰度值的概率 close all;clear all;clc; % 纹理图像的灰度差分统计特征 J = i ...

  10. ReDOS攻击

    正则表达式拒绝服务攻击(Regular Expression Denial of Service)当开发人员编写的正则表达式存在缺陷时,攻击者可以构造特殊的字符串来大量消耗服务器资源,最终造成拒绝服务 ...