If you are unable to log into SQL Server as a Domain User, and any local account (such as "sa") is disabled, you can follow the procedure below to log in using a local administrator (any account which is a member of the "Local Administrators" group), and perform a number of tasks.
1) Stop the SQL Server and SQL Server Agent services
2) Disable SQL Agent service
3) Run the following command to start SQL server in 'Single User Mode': sc start MSSQLSERVER -m
(Where MSSQLSERVER is the name of the SQL service)
4) From a command prompt, start a SQLCMD: SQLCMD -s (local)
5) Run the appropriate command for the task you are trying to achieve. For example:
a) To create a new local SQL administrator account:
1> CREATE LOGIN [NewAccount] WITH PASSWORD = N'[Password]',
2> DEFAULT_DATABASE = [master],
3> CHECK_EXPIRATION = OFF,
4> CHECK_POLICY = OFF
5> GO
1> ALTER SERVER ROLE [sysadmin]
2> ADD MEMBER [NewAccount]
3> GO
b) To reset the password of an existing account:
1> ALTER LOGIN [ExistingAccount] WITH PASSWORD = N'[Password]'
2> GO
c) To renable login for an existing account:
1> ALTER LOGIN [ExistingAccount] ENABLE
2> GO
6) Close the SQLCMD prompt
7) Stop the SQL Server Service
8) Enable the SQL Server Agent service
9) Start the SQL Server and SQL Server Agent services
You should now be able to log into SQL with either your new account, or the existing account that has been enabled or had its password reset.
I've been seeing quite some tutorials on problems regarding SQL, but I don't quite understand them. But this is really good you just described it really well helped me enough now i know the basic SQL. Want to learn more about database.
ReplyDelete