To solve the SQL Server administrator account without permission issues

Forget the situation encountered SQL Server administrator account password or administrator account is accidentally deleted, how to add a new administrator account in SQL Server? Click on the steps to add a windows account to SQL Server, and assign the database administrator privileges.

1. Run command prompt with administrator privileges.

 

2.  Enter the following command to stop running SQL server service 

NET STOP MSSQL$WINCC

 3. Enter the following command , enter the SQL Server in single-user mode 

NET START MSSQL$WINCC /m

4.  Open SQL Server Management Studio , do not enter the Explorer, click on " New Query ."

5. Enter the following code, the  domain \ username  changed to add an administrator privileges windows account. For computers not joined to a domain, domain name for the local computer.

USE master
GO
CREATE LOGIN  [domain\username]  FROM WINDOWS WITH DEFAULT_DATABASE=[Master]
GO
EXEC sp_addsrvrolemember @loginame=N'domain\username', @rolename=N'sysadmin'
GO

 6. Enter the following command in order to restart SQL server

NET STOP MSSQL$WINCC
NET START MSSQL$WINCC

 

Guess you like

Origin www.cnblogs.com/yada/p/11690846.html
Recommended