本文介绍了如何与同一台计算机上的其他用户共享SQL LocalDb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找使用sqllocaldb命令实用程序的share命令在用户之间访问LocalDb数据库的方法,但是我看不到一个用户在另一个用户中创建的数据库.

I am looking for ways to access LocalDb database between users using the share command of sqllocaldb command utility but I cannot see the database created in one user in another.

这是我的步骤:

  1. 在Windows 7上登录用户User1

  1. Login to user User1 on Windows 7

使用sqlcmd如下创建一个名为test的新数据库

Create a new database called test using sqlcmd as follows

sqlcmd -S(localdb)\ v11.0创建数据库测试

sqlcmd -S (localdb)\v11.0 create database test

按以下步骤与User2共享实例v11.0

Share the instance v11.0 as follows with User2

sqllocaldb共享域\ User2 v11.0 myinstance

sqllocaldb share domain\User2 v11.0 myinstance

切换到用户2

按以下步骤登录共享实例

Login to shared instance as follows

sqlcmd -S(localdb)\.\ myinstance

sqlcmd -S (localdb)\.\myinstance

从sys.master_files中选择名称

select name from sys.master_files

上面的查询不显示测试数据库.

The above query does not display test database.

为什么共享后我看不到用户1中创建的用户2中的数据库?

Why am I not able to see the databases in User 2 that was created in User1 after sharing?

我认为它必须基于博客(方法2) http://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full- Krzysztof Kozielczyk编写的iis-part-2-instance-ownership.aspx#SharedLocalDB ,但没有.

I thought it must work based on blog (approach 2)http://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-2-instance-ownership.aspx#SharedLocalDB by Krzysztof Kozielczyk but it does not.

感谢任何帮助/建议.

谢谢削皮

推荐答案

问题是LocalDB作为当前用户拥有的进程运行,这意味着每个用户都运行自己的LocalDB实例.这就是使其零配置且非常易于使用的原因.不幸的是,这也意味着很难拥有一个共享的LocalDB实例.我遇到了一个类似的问题,只是切换到使用SQL Express作为数据库,而开发中需要多个用户访问该数据库.

The problem is that LocalDB runs as a process owned by the current user, meaning each user runs their own instance of LocalDB. This is what makes it zero configuration and very easy to work with. Unfortunately, it also means it's difficult to have a shared LocalDB instance. I was running into a similar issue, and just switched to using SQL Express for a db I needed accessible by multiple users in development.

这篇关于如何与同一台计算机上的其他用户共享SQL LocalDb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 10:31