如何重置SQL Server 2008的用户名和密码

时间:2022-05-13 08:27:06

Shortly after I installed MS SQL Server 2008 on my machine, I forgot the password AND username that I chose. How can I reset them?

在我的机器上安装MS SQL Server 2008后不久,我忘记了我选择的密码和用户名。我该如何重置它们?

This question seems promising, but it didn't work for me.

这个问题似乎很有希望,但它对我没有用。

When I tried exec sp_password @new='changeme', @loginame='sa' as a query, I received:

当我尝试执行exec sp_password @ new ='changeme',@ loginame ='sa'作为查询时,我收到:

Msg 15151, Level 16, State 1, Line 1
Cannot alter the login 'sa', because it does not exist or you do not have permission.

3 个解决方案

#1


10  

Try following the instructions from this blog post entitled Disaster Recovery: What to do when the SA account password is lost in SQL Server 2005. It applies to SQL Server 2005, but should probably work with SQL Server 2008 as well.

请尝试按照此博客文章中的说明进行操作:灾难恢复:SQL Server 2005中SA帐户密码丢失时的操作。它适用于SQL Server 2005,但也可能适用于SQL Server 2008。

You need to start SQL Server in single user mode using the -m command line switch. When SQL Server has started, a Windows administrator can connect to SQL Server using Windows authentication. You can then reset the password of the sa user. Make sure to restart SQL Server without the -m command line parameter afterwards.

您需要使用-m命令行开关以单用户模式启动SQL Server。 SQL Server启动时,Windows管理员可以使用Windows身份验证连接到SQL Server。然后,您可以重置sa用户的密码。确保之后不使用-m命令行参数重新启动SQL Server。

#2


3  

Login as a Local or Domain Admins and just try to connect using "Windows Authentication".

以本地或域管理员身份登录,然后尝试使用“Windows身份验证”进行连接。

#3


-2  

If you don't have other SysAdmin privilege login - you have nothing but reinstall it. Otherwise use it to change password.

如果您没有其他SysAdmin权限登录 - 除了重新安装之外什么都没有。否则用它来更改密码。

#1


10  

Try following the instructions from this blog post entitled Disaster Recovery: What to do when the SA account password is lost in SQL Server 2005. It applies to SQL Server 2005, but should probably work with SQL Server 2008 as well.

请尝试按照此博客文章中的说明进行操作:灾难恢复:SQL Server 2005中SA帐户密码丢失时的操作。它适用于SQL Server 2005,但也可能适用于SQL Server 2008。

You need to start SQL Server in single user mode using the -m command line switch. When SQL Server has started, a Windows administrator can connect to SQL Server using Windows authentication. You can then reset the password of the sa user. Make sure to restart SQL Server without the -m command line parameter afterwards.

您需要使用-m命令行开关以单用户模式启动SQL Server。 SQL Server启动时,Windows管理员可以使用Windows身份验证连接到SQL Server。然后,您可以重置sa用户的密码。确保之后不使用-m命令行参数重新启动SQL Server。

#2


3  

Login as a Local or Domain Admins and just try to connect using "Windows Authentication".

以本地或域管理员身份登录,然后尝试使用“Windows身份验证”进行连接。

#3


-2  

If you don't have other SysAdmin privilege login - you have nothing but reinstall it. Otherwise use it to change password.

如果您没有其他SysAdmin权限登录 - 除了重新安装之外什么都没有。否则用它来更改密码。