如何在同一台机器上与其他用户共享 SQL LocalDb? [英] How to share SQL LocalDb with other users on same machine?

查看:32
本文介绍了如何在同一台机器上与其他用户共享 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 share domainUser2 v11.0 myinstance

sqllocaldb share domainUser2 v11.0 myinstance

切换到用户 2

登录共享实例如下

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.

为什么我在共享后看不到User1中创建的User2中的数据库?

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-iis-part-2-instance-ownership.aspx#SharedLocalDB 作者:Krzysztof Kozielczyk 但它没有.

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆