If you forget the SQL Server administrator password, you can use the following methods to deal with it
1. Use any member of the local Administrators group of the SQL Server server computer to log in to the SQL Server server
2. Determine the SQL server that has forgotten the administrator password Server service
can be viewed in the service (services.msc), or use the following Powershell command
Get-Service | ? DisplayName -Like 'SQL Server (*)'
3. Stop the SQL Server service
4. Start the SQL Server service in single-user mode (/m parameter)
Use the parameter /m to start and execute it at the administrator command prompt
net start start mssqlserver /m
5. Use slqcmd Completing Administrator Unlock
Starting SQL Server in single-user mode enables any member of the computer's local Administrators group to connect to the SQL Server instance as a member of the sysadmin fixed server role
6. When completed, stop the SQL Server service and run as Just start SQL Servr and related services in the normal way
Powershell universal script – add the current login account to the sysadmin member of SQL Server
# Script It needs to be executed in Powrshell under the administrator command prompt
# You can enter Powershell under the administrator command prompt through the following command
# Powershell Start- Process Powershell.exe -Verb runas
reportdb’ # 定义要操作的 SQL Server 服务 ServiceName # 停止 SQL Server 服务并以单用户模式启动 net.exe stop Service.Name) net.exe start Service.Name) /m # 当前用户加入 SQL Server 的 sysadmin 成员 Service.Name -Split ‘$’)[1] If( -Not user = [Environment]::UserDomainName + ‘\’ + [Environment]::UserName user] FROM WINDOWS; EXEC sp_addsrvrolemember [ Instance -Q $sql # 以正常方式启动 SQL Server 服务(依赖的服务需要手工检查启动) net.exe stop Service.Name) net.exe start Service.Name)
Additional Instructions
One way you can regain access is to reinstall SQL Server and attach all databases to New instance. This solution is time-consuming and may require restoring the master database from backup to restore the logins. If the backup of the master database is older, it may not contain all the information. If the backup of the master database is newer, it may have the same login as the previous instance; therefore the administrator will still be locked out.
This article explains how to deal with forgetting the SQL Server administrator password. For more related content, please pay attention to the php Chinese website.
Related recommendations:
A brief analysis of the use of concat and group_concat in MySQL
Introduction to MySQL graphical management tools
Related explanation of the basic functions of MySQL stored procedures
The above is the detailed content of What to do when you forget your SQL Server administrator password. For more information, please follow other related articles on the PHP Chinese website!