ESX Virtualization

VMware ESXi, vSphere, VMware Backup, Hyper-V... how-to, videos....

Nakivo Backup and Replication - #1 Backup solution for Virtual, physical, cloud, NAS and SaaS

Menu
  • Certification
      • VCP-DCV vSphere 8
          • vcp2024-125.
        • Close
    • Close
  • VMware
    • Configuration Maximums
    • vSphere
      • vSphere 8.0
      • vSphere 7.0
      • vSphere 6.7
      • vSphere 6.5
      • vSphere 6.0
      • Close
    • VMworld
      • VMware EXPLORE 2024
      • VMware EXPLORE 2023
      • VMware EXPLORE 2022
      • VMworld 2019
      • VMworld 2018
      • VMworld 2017
      • VMworld 2016
      • VMworld 2015
      • VMworld 2014
      • VMworld 2013
      • VMworld 2012
      • VMworld 2011
      • Close
    • Close
  • Microsoft
    • Windows Server 2012
    • Windows Server 2016
    • Windows Server 2019
    • Close
  • Categories
    • Tips – VMware, Microsoft and General IT tips and definitions, What is this?, How this works?
    • Server Virtualization – VMware ESXi, ESXi Free Hypervizor, VMware vSphere Server Virtualization, VMware Cloud and Datacenter Virtualization
    • Backup – Virtualization Backup Solutions, VMware vSphere Backup and ESXi backup solutions.
    • Desktop Virtualization – Desktop Virtualization, VMware Workstation, VMware Fusion, VMware Horizon View, tips and tutorials
    • How To – ESXi Tutorials, IT and virtualization tutorials, VMware ESXi 4.x, ESXi 5.x and VMware vSphere. VMware Workstation and other IT tutorials.
    • Free – Free virtualization utilities, ESXi Free, Monitoring and free backup utilities for ESXi and Hyper-V. Free IT tools.
    • Videos – VMware Virtualization Videos, VMware ESXi Videos, ESXi 4.x, ESXi 5.x tips and videos.
    • Home Lab
    • Reviews – Virtualization Software and reviews, Disaster and backup recovery software reviews. Virtual infrastructure monitoring software review.
    • Close
  • Partners
    • NAKIVO
    • StarWind
    • Zerto
    • Xorux
    • Close
  • This Web
    • News
    • ESXi Lab
    • About
    • Advertise
    • Archives
    • Disclaimer
    • PDFs and Books
    • Close
  • Free
  • Privacy policy

How to reset lost sa password in SQL express

By Vladan SEGET | Last Updated: January 20, 2016

Shares

If you are in front of a system where there is a SQL Express installed and you don't have the sa password for login in, you're basically stuck, because you have no way to log in and if you login as Windows user you have no rights over the instance and all commands will get you nice and long error message saying that you have no rights to do so! The mixed mode is Windows + SQL Server authentication. There can also be Windows authentication only. (it's a radio button to choose from). How to reset lost sa password in SQL express in this scenario?

Normally it's an easy process to change the authentication mode, but you must have the rights to do that….  All you have to do is to right click the SQL server Management studio object explorer > Properties > Server authentication > security > select new authentication mode > OK. But this won't happen as you have no rights.  So to help you out, follow today's guide.

This situation can easily happens in case you inherited an administration of server system with some SQLExpress DB installed or during some consulting at client's site… In many cases this can come handy and saves your day. .

You'll have to first change the authentication mode from SQL server authentication into Mixed mode > Then enable the sa user name > Do a reset of the sa password (assigning new password to the sa user).

How to reset lost sa password in SQL express – the steps:

First – it's necessary to change the authentication mode into Mixed mode. We'll use a registry hack for that as this is the only (I know) way to do that.

Open the registry editor and go to here:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.10.SQLEXPRESS\MSSQLServer

Change the value of LoginMode from 1 to 2

How to change login mode in SQL Express

Second – Now you can Enable the sa user account and do a reset of a password.

  • You'll have to first start services.msc console and stop the SQLEXPRESS service
  • Enter -m into the “Start Parameters” field
  • Start the service
  • Open command prompt and enter this command:

osql -S YOUR_SERVER_NAME\SQLEXPRESS -E

so in my case it was a mirage server VM which netbios name was mirage. So I entered:

osql -S MIRAGE\SQLEXPRESS -E

It depends of the name of your system…..so dont put the name ‘YOUR_SERVER_NAME'… -:) I won't work..

Third – there will be a prompt with numbers in front. Go and enter exactly this (except the new_password)

1> alter login sa enable
2> go
1> sp_password NULL,'new_password','sa'
2> go
1> quit

How to reset SQL Express sa password

note in this example the password is Totogogo007*

  • Stop the SQLEXPRESS service once again
  • Remove the -m from the start parameters field
  • Start the service

How to reset lost sa password in SQL express

You're done! Now you should be able to login into SQL server management studio by using the sa user account and the new password…..

During the installation of SQL server database (express or standard) the DB engine is set to either Windows authentication mode or SQL server and Windows authentication mode.

Source: Partly from MSDN

Update: There is another option to gain an access to the SQL server (without restarting the DB). Thanks to Genadi for the comment and source.

Step 1: login with an acccount which is in the local administrator group

Step 2: Use PsExec to start the SQL server management studio as NT AUTHORITY\SYSTEM account which has an access to SQL server

From the source:

Source here

Download and extract PsExec.exe. Start an elevated command prompt (Shift + Right-click, “Run as Administrator”). Run the following command, adjusting for your actual path to Management Studio, which may be different:

PsExec -s -i “C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe”

This command tells PsExec to run SSMS interactively (-i) and as the system account (-s).

While I haven't tested this personally, it seems that the NT AUTHORITY\SYSTEM account does the trick…. Good stuff -:)

Shares
5/5 - (1 vote)

| Filed Under: How To Tagged With: How to reset lost sa password in SQL express

About Vladan SEGET

This website is maintained by Vladan SEGET. Vladan is as an Independent consultant, professional blogger, vExpert x16, Veeam Vanguard x9, VCAP-DCA/DCD, ESX Virtualization site has started as a simple bookmarking site, but quickly found a large following of readers and subscribers.

Connect on: Facebook. Feel free to network via Twitter @vladan.

Comments

  1. Genadi says

    January 20, 2016 at 4:25 pm

    Hi Vladan,
    I just want to comment on some sentences written in this article.
    Regarding “I suppose that the system authentication mode is set as SQL Server authentication only and not mixed. The mixed mode is Windows + SQL Server authentication. “.
    Authentication in SQL servers can be Windows authentication and mixed mode(Windows + SQL Server authentication), there isn’t SQL Server authentication only, as it’s written.
    Also if you don’t have permissions on database, it’s not necessary to give permissions to sa account. You can give permissions to your personal account or group. Users added in Built-in Administrators group have access to SQL server when sql server is started with option -m. So after starting sql server with option -m, you can add your account as login with sysadmin priviliges:
    o create a new login and add that login to SYSADMIN server role:
    1> CREATE LOGIN ‘’ with PASSWORD=’’
    2> go
    1> SP_ADDSRVROLEMEMBER ‘’,’SYSADMIN’
    2> go
    To add an existing login to SYSADMIN server role, execute the following:
    1> SP_ADDSRVROLEMEMBER ‘’,’SYSADMIN’

    The above operation will take care of granting SYSADMIN privileges to an existing login or to a new login.

    I want also point that running sql server with option -m means that only one connection is possible, so you need first to stop the application that is using it( like vcenter server for example).

    SQL Server best practices are to use windows authentication, and not using the sa account.

    #########
    I also found another good way to gain access to sql servers(express edition also). By default when slq server is installed account NT AUTHORITY\SYSTEM is added. You can access the sql server with this account. Here is an article how to do this: https://www.mssqltips.com/sqlservertip/2682/recover-access-to-a-sql-server-instance/

    • Vladan SEGET says

      January 20, 2016 at 6:04 pm

      Hi Genadi,

      Great comment. Thanks.

      However I think that I wrongly put the sentence about the mixed and Windows auth. I’ll correct the post.

      I definitely needs to look a bit further on SQL as I don’t spend enough time on that. I definitely prefer to share accurate informations which helps the community.

      Thanks again for that addition,
      Vladan

  2. Genadi says

    January 20, 2016 at 7:46 pm

    Hello Vladan,

    Just to say that both options for gaining access to the DB, which I explain requires DB restart.

    I’ll give you the links for the articles, which I used as a source of information.

    1st option to gain access to SQL server – https://ramazancan.wordpress.com/2011/06/14/you-have-lost-access-to-sql-server-how-to-fix-it/

    2nd option to gain access to SQL server – https://www.mssqltips.com/sqlservertip/2682/recover-access-to-a-sql-server-instance/

    • Genadi says

      January 20, 2016 at 7:48 pm

      Sorry, mistype, the second option doesn’t require restart.

  3. Fercho says

    September 7, 2019 at 2:45 am

    Hola, muchas gracias por tu post, me sirvió mucho y pude resolver el problema.

  4. geoff bleakley says

    October 24, 2019 at 8:00 pm

    Thanks for the first comment regarding the alternate sysadmin users

Private Sponsors

Featured

  • Thinking about HCI? G2, an independent tech solutions peer review platform, has published its Winter 2023 Reports on Hyperconverged Infrastructure (HCI) Solutions.
  • Zerto: One Platform for Disaster Recovery, Backup & Cloud Mobility: Try FREE Hands-On Labs Today!
Click to Become a Sponsor

Most Recent

  • Veeam Backup & Replication v13 Beta: A Game-Changer with Linux
  • What is Veeam Data Cloud Vault and how it can help SMBs
  • Nakivo Backup and Replication – Malware Scan Feature
  • Zerto 10 U7 released with VMware NSX 4.2 Support
  • XorMon NG 1.9.0 Infrastructure Monitoring – now also with Veeam Backup Support
  • Heartbeat vs Node Majority StarWind VSAN Failover Strategy
  • Vulnerability in your VMs – VMware Tools Update
  • FREE version of StarWind VSAN vs Trial of Full version
  • Commvault’s Innovations at RSA Conference 2025 San Francisco
  • VMware ESXi FREE is FREE again!

Get new posts by email:

 

 

 

 

Support us on Ko-Fi

 

 

Buy Me a Coffee at ko-fi.com

Sponsors

Free Trials

  • DC Scope for VMware vSphere – optimization, capacity planning, and cost management. Download FREE Trial Here.
  • Augmented Inline Deduplication, Altaro VM Backup v9 For #VMware and #Hyper-V – Grab your copy now download TRIAL.

VMware Engineer Jobs

VMware Engineer Jobs

YouTube

…

Find us on Facebook

ESX Virtualization

…

Copyright © 2025 ·Dynamik-Gen · Genesis Framework · Log in