SQL Server Troubleshooting: Restore the sa password
First or all we must stop the SQL Server service.
Start the SQL Server service in (Single-User Admin Mode) mode, to do it, launch the command line as an administrator, then type this command (SQLServr.exe -m ou SQLServr-f) :
- SQLServr.exe -m : Single User Admin Mode.
- SQLServr.exe -f : Minimal Configuration Mode, ii include (Single User Admin Mode), the command (SQLServr.exe) exists in this path : (C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Binn).
- Keep the window open.
Now open a new window as administrator, then launch this command (SQLCMD -s <Serveur\Instance>). Ex : SQLCMD -s "MonServeur"
Create the login :
Create Login MonCompte With PassWord='MonMotDePasse'
Go
Add the login to the SysAdmin role :
Now we must change the authentication mode of SQL Server (Mixte : Windows et SQL Server), subject to the following registry key :
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE',N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', REG_DWORD, 2
GoFinally restart the SQL Server service in normal mode.