简体   繁体   English

远程计算机上的SQL Server

[英]SQL Server on remote computer

I have a SQL Server Express instance on a computer with IP 192.168.66 on a home network. 我在家庭网络上IP为192.168.66的计算机上有一个SQL Server Express实例。

I have enabled TCP/IP on port 49170 and added the incoming rule on Windows firewall. 我已在端口49170上启用了TCP / IP,并在Windows防火墙上添加了传入规则。

I have an application that I want to install on different computers inside my network. 我有一个要安装在网络内部不同计算机上的应用程序。 When I am testing my application in Visual Studio, I am not able to connect to my instance on the remote computer. 在Visual Studio中测试应用程序时,无法连接到远程计算机上的实例。

<connectionStrings>
    <add name="EquipamentoDal.Properties.Settings.ExtinguisherMngConnectionString"
         connectionString="Data Source=192.168.1.66,49170;Initial Catalog=ExtinguisherMng;Integrated Security=True"
         providerName="System.Data.SqlClient" />
 </connectionStrings>

The server name is DESKTOP-HU51203\\EXPRESS . 服务器名称为DESKTOP-HU51203\\EXPRESS What i have done wrong to not be able to connect? 我做错了什么而无法连接?

Your connection string does not specify the Named Instance you're connecting to, it only specifies the IP address, which means any clients will connect to the default instance instead of a named instance. 您的连接字符串未指定您要连接的命名实例,而仅指定IP地址,这意味着任何客户端都将连接到默认实例,而不是命名实例。

By default SQL Server Express is configured differently to 'standard' versions of SQL Server (Standard, Workgroup, Developer, and Enterprise Editions) as follows: 默认情况下,SQL Server Express的配置与SQL Server的“标准”版本(Standard,Workgroup,Developer和Enterprise Edition)不同,如下所示:

  • Block incoming remote connections - this must be explictly enabled in the SQL Server Configuration Manager 阻止传入的远程连接-必须在SQL Server配置管理器中明确启用
  • Use a Named Instance called SQLEXPRESS instead of being configured as the Default Instance 使用名为SQLEXPRESS命名实例,而不是配置为默认实例
  • SQL Server Express is also unique in supporting AttachDb and LocalDb - the other SKUs/Editions do not support the AttachDb and LocalDb features. SQL Server Express在支持AttachDbLocalDb也很独特-其他SKU /版本不支持AttachDbLocalDb功能。

In your case, you've already enabled Remote Connections and you're not using AttachDb or LocalDb , so you just need to configure your client to connect to a named instance: 在您的情况下,您已经启用了远程连接,并且没有使用AttachDbLocalDb ,因此只需要配置客户端以连接到命名实例:

You specify the named instance in your connection string using the format <host>\\<instance name>,<port> in the Data Source= or Server= parameter, eg Data Source=foo\\SQLEXPRESS,1433 , or in your particular case: 您可以使用Data Source=Server=参数中的格式<host>\\<instance name>,<port>在连接字符串中指定命名实例,例如Data Source=foo\\SQLEXPRESS,1433 ,或者在您的特定情况下:

Data Source=192.168.1.66\SQLEXPRESS,49170;Initial Catalog=ExtinguisherMng;Integrated Security=True

You mentioned that you're doing this on a Home network, which means it's unlikely you're using an Active Directory or Kerberos, and given SQL Server Express does not expose the passwords it uses for its Service Identity (nor can users authenticate as NT AUTHORITY\\NetworkService over the network it means you cannot use Integrated Security=True (or Integrated Security=SSPI which is equivalent, but SSPI is the preferred value), you will need to set an explicit SQL Server Login's username and password in your Connection String. 您提到要在家庭网络上执行此操作,这意味着您不太可能使用Active Directory或Kerberos,并且由于SQL Server Express不会公开用于其服务身份的密码(用户也不能通过NT AUTHORITY\\NetworkService身份验证)通过网络的NT AUTHORITY\\NetworkService ,这意味着您不能使用Integrated Security=True (或Integrated Security=SSPI ,这是等效的,但SSPI是首选值),您将需要在连接字符串中设置显式SQL Server登录名的用户名和密码。

  1. Create a new Login object in the Server (you will need to login to the server first somehow, either locally or remotely using the sa account, if it exists) 在服务器中创建一个新的登录对象(您需要首先以某种方式(使用sa帐户在本地或远程登录)以某种方式登录到服务器)
  2. Specify the new Login's credentials by replacing Integrated Security=True with User Id=<userName>;Password=<password>; 通过将Integrated Security=True替换为User Id=<userName>;Password=<password>;指定新的登录名的凭据User Id=<userName>;Password=<password>;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试从远程计算机上的程序连接到SQL Server时出错 - Error when trying to connect to SQL Server from program on remote computer 远程计算机登录上SQL Server Express的连接字符串失败错误 - Connection string for SQL Server Express on remote Computer login failed error 停止/启动服务或关闭远程计算机上的sql server进程/服务 - stop / start service or close the sql server process / service on a remote computer 以编程方式将远程计算机的时间服务器设置为与控制计算机匹配? - Programatically set the time server of a remote computer to match the control computer? 远程SQL Server的ConnectionString - ConnectionString for remote SQL Server 用户客户端计算机的 SQL Server 登录失败 - SQL Server login failed for user client computer 从另一台计算机连接到SQL Server - Connecting to SQL server from another computer 当连接到远程计算机上的WMI时,RPC服务器不可用 - RPC server is unavailable when connecting to WMI on a remote computer C#在单独的DNS服务器上获取远程计算机的IP - C# Get IP of Remote Computer on Separate DNS Server 从服务器到本地网络中的远程计算机的弹出对话框 - Popup dialog from server to remote computer in local network
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM