I've forgotten my sa password and already disabled windows authentication mode.
How can I reset SQL Server sa password with disabled windows authentication
tnx in advance
New best way: Use PowerShell. Reset-SqlSaPassword allows administrators to regain access to local or remote SQL Servers by either resetting the sa password, adding sysadmin role to existing login, or adding a new login (SQL or Windows) and granting the login sysadmin privileges. Windows administrator access is required.
This is accomplished by stopping the SQL services or SQL Clustered Resource Group, then restarting SQL via the command-line using the /mReset-SqlSaPassword paramter which starts the server in Single-User mode, and only allows Reset-SqlSaPassword to connect.
Once the service is restarted, the following tasks are performed:
Login is added if it doesn't exist
List item
Login is enabled
Login is added to sysadmin role
Login is unlocked
If login is a Windows User, an attempt is made to ensure the account exists
If login is a SQL Login:
A secure password prompt will appear
Password policy is set to off
SQL Server authentication is set to Mixed Mode
In order to make this script as portable as possible, System.Data.SqlClient and Get-WmiObject are used (as opposed to requiring the Failover Cluster Admin tools or SMO). If using this function against a remote SQL Server, ensure WinRM is configured and accessible. If this is not possible, run the script locally. Works on x86 and x64.
I had the same problem. Tried googling it and all the standard solutions didn't work so I had to get creative. Essentially my problem was that the SA account was disabled, also the system was set to only allow login by windows authentication, and finally the administrator account in windows also was not a member of the sysadmin role. So all the normal suggestions kept giving me permission denied errors (because I didn't have permissions to alter what other posts were telling me I should alter).
My solution is documented below, only apply the parts you need:
Stage 1: - Get SSMS working in single user mode
Open Sql server configuration manager (SSCM)
Click on SQL Server Services
Right click on SQL Server (MSSQLSERVER) and click properties
Click on the advanced tab
Find "Startup Parameters" and add the following
"-m;" at the beginning or ";-m" at the end (note the semi-colons but without quotes)
be careful to not add any white spaces as the parser is very picky
Press ok
Right click again and press restart
If you get any problems with the service not starting, verify step 5.
Stage 2: Part 1: - Enabling SQL Server and Windows Authentication mode
Start SSMS again.
This time when SSMS starts it will start in Single user mode which gives you full access.
Login with the usual windows account as before.
Right click on the server node (the very first / topmost node) and choose properties.
Click on Security
Under "Server authentication" click on "SQL Server and Windows Authentication mode" if its not already selected.
Click ok
Stage 2: Part 2: - Adding yourself into the sysadmin role
Click on "Security" and then "Server Roles"
Right click on "sysadmin" role
In the window that pops up, click add at the bottom.
In the window that pops up, click browse
Find your user and click the checkbox beside the name.
Click ok - this will return you to window in step 4 which will now have your user(s) in the lower box.
Click ok - this will return you to the window in step 3 which will add your user(s) to the role members list.
Click ok. - Congrats, you now have all the rights of the SA user.
Stage 2: Part 3: Altering the SA Password and enabling the account
Double Click on Security.
Double Click on Logins.
Right click on SA and choose properties.
Change and confirm the password fields (But don't press ok yet).
Click on the Status tab.
Click on Enabled.
Click ok
This is the process for resetting any users password (for a sysadmin).
At this stage you should close SSMS.
Stage 3: Restarting SSMS in multi user mode.
Follow the steps taken in Stage 1 and simply remove the -m;
Stage 4: Trying on your bigger shoes.
At this stage you should be able to enable or disable the SA account from your login and change its password, also you should be able to enable or disable the ability to login with SQL Server authentication. Test these to ensure you have necessary rights.
Notes: Some taught should go into doing this. I feel that a sysadmin account should be the first thing setup once you setup a new SQL server instance.
Some people recommend removing the SA account (Personally, I recommend just putting a really strong password on it). As long as you have an account with sysadmin this is fine but someone must have an account with sysadmin access. This account should not be named Admin or some variant thereof like God for obvious reasons. Also avoid names such as your business name and combinations of either etc.
As regards to enabling or disabling sql server authentication that's a debate I'll leave for the DB admins.
Hope you find this helpful.
If you lost sa password and dont have windows authentication login,then sa password can be reset by following steps-:
1.Start SQL Server in single user mode.
(a) open sql server configuration manager
(b) Select your instance and click properties,and set -m of -f parameter in
enter image description here startup parameter.
(c) Click ok,and then restart SQL service .
2.Now all the users who are a member of the host’s local administrator group can connect to SQL Server instance and they will gain the privileges of server level role sysadmin which helps us to recover SA password.
3.Run SSMS (Sql Server Management Studio) as administrator,and login by windows authentication.
4.Now select security tab and select logins and find 'sa' user and select properties,and reset desired password.
5.Then again restart SQL SERVER INSTANCE by right clicking on it.
enter image description here
6.Now sa password has been reset.
7.Now remove -f or -m parameter from SQL Server Configuration startup parameters.enter image description here
8.Again restart SQL SERVER SERVICE by right clicking on instance in configuration manager.
9.Now you have successfully reset sa password of SQL Server and check it by running SSMS and set SQL Server authentication mode in management studio.
Simple steps for SQL Server 2008+, which no longer have Admin group added by default.
From command line (as a Win admin):
net stop MSSQLSERVER
net start MSSQLSERVER /m /f
ssms
Here (in the launched SSMS) you can create additional sysadmins, change the sa password. Then back to the command shell:
net stop MSSQLSERVER
net start MSSQLSERVER
Here is a step by step 5 minute video on how to reset the SysAdmin password using either SQL Server Authentication or Windows Authentication
https://www.youtube.com/watch?v=GOvbjo1tlYo
The basic steps is also to start SQL Server in Single User Mode, then adding a new SysAdmin user. The basic steps highlighted in the video is as follows
Start Single User Mode Step by Step
SQL Server Configuration Manager - Make sure to enable NamedPipes/TCP Locally
List the Services
a. net start
b. services.msc
Stop the Service - net stop [SQL-SERVICENAME]
Start Single User Mode
a) net start [SQL-SERVICENAME] -m"SQLCMD"
b) "C:\Program Files\Microsoft SQL Server\MSSQL14.SQL1\MSSQL\Binn\sqlservr.exe" -sSQL1 -m"SQLCMD"
SQLCMD -S [SQL INSTANCE]
sqlcmd - Login
a) SQL User - CREATE LOGIN [name] WITH PASSWORD='password'; GO
b) Windows User - CREATE LOGIN [domainName\login_name] FROM WINDOWS; GO
sqlcmd
a) SP_ADDSRVROLEMEMBER name,'SYSADMIN'; GO
b) Confirm - SELECT name FROM syslogins; GO;
sqlcmd - exit
Related
Originally, I can connect to localhost in SQL Server through Windows authentication. But after I changed the login password of PC, I can't. Could you please help me figure out why?
Not too much information provided... but that is common issue for many users.
Check the server account name in the SQL Server Configuration Manager. If you run it under your account, you have to change the password for that service and restart it, or change it to use LocalSystem account.
Open CMD (Ctrl+r) input "services.msc"
Right Click SQL Server (Your Instance) - Properties
Click Tab Log On
Fill this account : your user login
Fill password : your user password, then confirm password then Ok.
Back to services Right click your SQL Server [Instance Name] - Start (picture 1)
Try re-login using windows account at SSMS
I recently set up SQL Server 2014 Express on my computer. During the installation process I merely selected Windows authentication, assuming I would be able to create other accounts later. I tested several things with C# using integrated authentication.
The problem arose when I attempted to use an account. I logged in using Windows authentication to change the sa password in SQL Server Management Studio. But when I attempt to so, and close the dialog, open it again, then the password is back to the 15 character default which I do not know. Enforce Policy is not on and I have no idea what might be causing this...
You need to check if you've enabled mixed mode authentication by:
right click on Server name after you've logged in as a windows user
Click Properties
Click Security
Check that the 'SQL Server and Windows Authentication mode' option is selected.
Then you can change the password for sa by going expanding the Server item and going to Security -> Logins -> Right click on sa -> Click Properties
Change the password here and CLICK OK.
Log out, log back in as sa, after selecting SQL Server Authentication just above where you enter the user name.
I am having quite a problem with SQL Server.
When I installed it, my account was not an administrator, now it is. Apparently, since it was not an administrator of the machine, it is not an administrator of SQL Server, as a consequence I cannot create databases on my machine.
Now, I am on Windows 8, so it seems like SQL Server Configuration Manager is not as accesible as it was before, I managed to run it (I THINK!) from the MMC by running the following command: sqlservermanager10.msc.
Now, can anyone help me configure my current user as an SQL Server admin so I can create databases properly?
Thank you!
if I understand you correctly, you want your account to have sysadmin rights on SQL Server. You can either do this via SQL Server Management studio, or the SQLCMD command line utility. You don't use the SQL Server Configuration Manager.
You need to login as an existing SA (or whichever the identity has the sysadmin role).
Using TSQL via SQLCMD
Run the following command (replacing domain\user with your details)
USE [master]
GO
CREATE LOGIN [domain\user] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
ALTER SERVER ROLE [sysadmin] ADD MEMBER [domain\user]
GO
Via the UI
In SQL Server Management Studio
Navigate to the Security node of the server, and R-Click & Select New Login
In the New Login dialog enter your domain user into the Window Authentication box
Then on the Right side select Server Roles and then make sure SysAdmin is selected
Then Ok that dialog and the windows account will have SA rights. This means then you can full administer the SQL Server.
It's not clear at all what's going on here, but it sounds to me like you haven't got any sysadmins if #Preet isn't correct.
The local Administrators group is not a member of the sysadmin role on recent versions of SQL Server (2005+, IIRC), and if I recall the installer complains if you try to configure it that way. Instead, when you install the instance you specify the users or groups who will be granted the sysadmin role on the instance.
If you did not do this (I think it adds the account doing the installation by default) or used an account or group which was later deleted, had the SID changed, or some similar event, then you have an instance with no sysadmin logins that can authenticate. You may be able to add one by switching the server to single user mode or minimal configuration mode (-f instead of -m).
If none of that works, then you'll have to save your database files, nuke the instance, install the instance again, re-attach your database files, and go from there.
The only other thing I can think that it might be is that the instance is somehow running as a user account that doesn't have permissions to create files in the default database or log directory, but that seems highly unlikely.
So I've been tasked to install DNN onto my system. I am using the Microsoft Web Platform Installer. I am being asked for the password for the 'sa' account. I do not know the password for the account. So when I tried to use the Microsoft SQL Server Management software to change the password I get the following message:
"Change password failed for Login 'sa' (Microsoft.SqlServer.Smo)
Additional Information:
An exception occurred while executing a Transact-SQL or batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot alter the login 'sa', because it does not exist or you do not have permission. (Microsoft SQL Server, Error: 15151)"
How would I obtain permission to change the password? Or am I missing the point entirely and should be doing something else to install the software??
I would assume the issue lies with SQL, what steps should I take to rectify this problem??
SQL Server uses either/both of "Windows authentication" and "SQL Server authentication".
By default, MSSQL installs with ONLY "Windows authentication". "sa" requires MSSQL authentication.
SOLUTION:
http://technet.microsoft.com/en-us/library/ms188670.aspx
1) Go into SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
2) On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
3) In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.
4) In Object Explorer, right-click your server, and then click Restart.
Are you able to login via Windows Authentication and change it that way? If so, that would be the best way to do it.
If the only account that has admin access is the sa account though, then you can try starting SQL server in single user mode and then resetting the sa password. Note that this method requires local admin access to the server itself.
http://sigkillit.com/2013/01/02/recover-sa-password-on-microsoft-sql-server/
Sounds to me like you could login with the SA account into SQL server, it will likely prompt you to change your password (first time logging in) and then you would be good to go after that.
That being said, I never recommend setting up DNN to connect to SQL server with the SA account. Each DNN database should have its own DB user, that way if one DNN install gets compromised for some reason, they can't reach out into other databases on the same server.
EDIT: a little more info
From http://www.christoc.com/Tutorials/All-Tutorials/aid/1
In SQL Server you should go through and create a new database. I always create a database with the same name as the website, so in this case DNNDEV.ME. Once you have created the database, create a user that can access that database. I always use SQL authentication, turn off the enforce password requirements, and give the user DB Owner and Public access to the DNNDEV.ME database. Remember the username and password you create here as you will need them when you walk through the Installation screen for DotNetNuke.
This is rather embarrassing, but I accidentally deleted my Windows account from the list of SQL Server 2008 users and I cannot for the life of me figure out how to re-add myself now that I don't have login privileges.
The server is running on my machine and the only other Windows users with access are IUSR, NETWORK SERVICE and SYSTEM. Is there anything I can do short of re-installing?
I also recently deleted my windows account from my local development 2008 server. I was able to use SQL server's Single User Mode to recreate my login and add it to the sysadmin role. It took just a few minutes, and I didn't have to admit my terrible error to anyone.
From MSDN:
Starting SQL Server in single-user mode enables any member of the
computer's local Administrators group to connect to the instance of SQL
Server as a member of the sysadmin fixed server role.
Here's how I reinstated myself:
Exit out of SSMS
Stop any SQL related services. I had to stop Reporting Services. Other SQL services such as SQL Agent will also use up your one, valuable connection.
Stop the SQL service
Start the SQL service with the extra parameter -m. This will put the SQL into Single User Mode. This means that SQL will only accept one connection.
Use sqlcmd to connect to your server with the -E trusted connection option. SQL will accept you into the sysadmin role if you're a local administrator.
In the interactive session, create your login and add to the sysadmins role.
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
Stop the SQL service, remove the -m parameter and restart the service. You should now be able to go back into SSMS and continue using the server normally.
If you get the message:
Login failed for user 'domain\username'. Reason: Server is in single user
mode. Only one administrator can connect at this time.
Then there is something using your single connection. You'll need to find that service or connection and stop it before you can log in. Check SQL Agent, SQL Reporting Services, SQL Analysis Services etc.
Luckily, this wasn't too hard to fix (not that it should have been hard...)!
This blog post explains the steps for starting SQL Server in Single User Mode, which (for some reason) allowed me to login as my Windows administrator account, add the account to the user list (with CREATE LOGIN), enable the SA user and set its password to something I actually knew, and finally login as SA and give the Windows account sysadmin privileges.
Edit 07/05/13: Try this link instead.
Often SQL Server is installed so that any any local administrator is a SQL Server sysadmin.
If this is your case you can run Management Studio as administrator and then add any other windows user as a login in the Security section.
This solution worked for me.