最近我的电脑正在维修,我使用了公司备用笔记本电脑(通用用户设置)。登录数据库时,我勾选了SQL Server管理工具中的“记住密码”选项。
为了防止下一个使用笔记本电脑的人使用我的登录名和密码,我需要清除已使用的登录名和密码信息。我该如何做?
最近我的电脑正在维修,我使用了公司备用笔记本电脑(通用用户设置)。登录数据库时,我勾选了SQL Server管理工具中的“记住密码”选项。
为了防止下一个使用笔记本电脑的人使用我的登录名和密码,我需要清除已使用的登录名和密码信息。我该如何做?
SQL Server Management Studio 2017 删除文件
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\14.0\SqlStudio.bin
SQL Server Management Studio 2016 删除文件
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\13.0\SqlStudio.bin
SQL Server Management Studio 2014 删除文件
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\12.0\SqlStudio.bin
SQL Server Management Studio 2012 删除文件
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\11.0\SqlStudio.bin
SQL Server Management Studio 2008 删除文件
C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin
SQL Server Management Studio 2005 删除文件-与上面的答案相同,但是Vista路径。
C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat
这些是Vista / 7/8的配置文件路径。
编辑:
注意,AppData
是一个隐藏文件夹。您需要在资源管理器中显示隐藏的文件夹。
编辑:您可以直接从服务器/用户名下拉列表中删除(已确认在SSMS v18.0上可用)。原始来源:https://blog.sqlauthority.com/2013/04/17/sql-server-remove-cached-login-from-ssms-connect-dialog-sql-in-sixty-seconds-049/提到此功能自2012年以来就已经可用!
这适用于SQL Server Management Studio v18.0
文件“SqlStudio.bin”似乎已经不存在了。相反,我的设置都存储在此文件中:
C:\Users\*********\AppData\Roaming\Microsoft\SQL Server Management Studio\18.0\UserSettings.xml
Ctrl + F
查找要删除的用户名<Element>.......</Element>
块。编辑: 对于v18.0(预览7),甚至更简单且有效的解决方案是:
对于那些寻找SSMS 2012解决方案的人...请参考这个答案:
基本上,在2012中,您可以从服务器列表下拉菜单中删除服务器,以清除该服务器的所有缓存登录。
在v17(版本号为14.x)中也可以使用此方法。
在我的情况下,我只想从保存了许多其他连接的列表中删除特定的用户名/密码,我不想忘记这些连接。事实证明,这里讨论的SqlStudio.bin
文件是Microsoft.SqlServer.Management.UserSettings.SqlStudio
类的.NET二进制序列化,可以进行反序列化、修改和重新序列化以修改特定设置。
为了实现删除特定登录信息,我创建了一个新的C# .Net 4.6.1控制台应用程序,并添加了对位于以下dll中的命名空间的引用:C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\Microsoft.SqlServer.Management.UserSettings.dll
(根据SSMS版本,您的路径可能略有不同)
从那里,我可以轻松地创建和修改所需的设置:
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Microsoft.SqlServer.Management.UserSettings;
class Program
{
static void Main(string[] args)
{
var settingsFile = new FileInfo(@"C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\13.0\SqlStudio.bin");
// Backup our original file just in case...
File.Copy(settingsFile.FullName, settingsFile.FullName + ".backup");
BinaryFormatter fmt = new BinaryFormatter();
SqlStudio settings = null;
using(var fs = settingsFile.Open(FileMode.Open))
{
settings = (SqlStudio)fmt.Deserialize(fs);
}
// The structure of server types / servers / connections requires us to loop
// through multiple nested collections to find the connection to be removed.
// We start here with the server types
var serverTypes = settings.SSMS.ConnectionOptions.ServerTypes;
foreach (var serverType in serverTypes)
{
foreach (var server in serverType.Value.Servers)
{
// Will store the connection for the provided server which should be removed
ServerConnectionSettings removeConn = null;
foreach (var conn in server.Connections)
{
if (conn.UserName == "adminUserThatShouldBeRemoved")
{
removeConn = conn;
break;
}
}
if (removeConn != null)
{
server.Connections.RemoveItem(removeConn);
}
}
}
using (var fs = settingsFile.Open(FileMode.Create))
{
fmt.Serialize(fs, settings);
}
}
}
SqlStudio.bin
文件,你会看到..UserSettings
和..UserSettings.SqlStudio
两个内容。从那里,很容易在与ssms.exe
相同的目录下找到..UserSettings.dll
,其中包含了命名空间和类。 - NeilMicrosoft.SqlServer.Management.UserSettings, Version=14.0.0.0, Culture=neutral...
,你教会了我如何钓鱼,感谢。 - Dr Manhattan使用更新版本的SQL Server Management Studio(我使用的是18.4),有一种非常简单的方法可以实现此操作。
登录已经消失!无需操作dll或bin文件。
SqlStudio.bin
。我还发现在C:\Users\userName\AppData\Roaming\Microsoft\SQL Server Management Studio\18.0
中有一个名为UserSettings.xml
的文件。但是删除包含凭据的<Element>
似乎行不通,如果我关闭并重新打开它,它会马上回到xml文件中。UserSettings.xml
文件。我猜这个文件除了在xml文件中之外还被缓存在SSMS的某个地方?而且它并不在控制面板\所有控制面板项\凭据管理器\Windows凭据
中。对于 SQL Server Management Studio 2008
您需要前往 C:\Documents and Settings\%username%\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell
删除 SqlStudio.bin
删除:
C:\Documents and Settings\%您的用户名%\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat"
C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin
这个文件对我有用。 - IsmailS