简体   繁体   中英

Access a sql data base from another computer

I have a SQL Server 2008 Express database and currently the database is on my personal laptop. I want to access my database from another computer which belongs to the same local area network. I am using Windows authentication to log in to SQL Server.

My connection string is as follows.

Data Source=.\sqlexpress;Initial Catalog=Project_Monitoring;Integrated Security=True

Please explain how to do the setting for above requirement. Thanks in advance.

You still need to allow SqlExpress to allow remote connections. On the machine that is hosting the SqlExpress process you need to do the following

  • Enable remote connections on the instance of SQL Server that you want to connect to from a remote computer.

  • Configure SQL server to listen on static port Turn on the SQL Server Browser service.

  • Configure the firewall to allow network traffic that is related to SQL Server and to the SQL Server Browser service.

See here http://blog.citrix24.com/configure-sql-express-to-accept-remote-connections/

The article uses 2012 as an example, but this the process is the same for any version of SqlExpress

As well as change the connection string on remote computers to

Data Source=<hostcomputername>\sqlexpress:<configured-port>;Initial Catalog=Project_Monitoring;Integrated Security=True

By default, SQL Server Express does not add a firewall rule, and it has the TCP protocol disabled. Therefore, you need to add these in order to be able to connect.

Open "SQL Server Configuration Manager". In the management console, open the "SQL Server Network Configuration" tab, protocols, TCP/IP, enable. Restart the service for the changes to be applied. Also, you might need to enable and start the "SQL Server Browser" service in "SQL Server Services".

Open Windows Firewall with Advanced Security, Inbound Rules, Add new rule, Custom, Services, Apply to this service: "SQL Server (SQLEXPRESS)", OK, Next... until you can name and finish the rule. Do that again for the Browser Service.

The server name is then the remote computer name instead of . , the rest of the connection string remains the same.

Note that you might run into authentication problems if the accounts are not trusted on the remote computer; for instance if you're not in a domain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM