다음을 통해 공유


SQL Server Troubleshooting: Restore the sa password

  1. First or all we must stop the SQL Server service.

  2. 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) :

    1. SQLServr.exe -m : Single User Admin Mode.
    2. 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).
    3. Keep the window open. 
        
  3. Now open a new window as administrator, then launch this command (SQLCMD -s <Serveur\Instance>). Ex : SQLCMD -s "MonServeur"

  4. 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 
    Go   

  • Finally restart the SQL Server service in normal mode.