SQL SERVER local administrator and SA account cannot log on

Source: Internet
Author: User

SQL SERVER local administrator and SA account cannot log on
These days I am going to talk about the SQL Server 2008 course. On the first day of today, the organizer prepared the environment to use the same virtual machine, and then distributed it to many experimental machines, the computer name was modified using a tool such as sysprepare. Early in the morning, you may not be able to log on to SQL Server, whether using a local administrator or an SA account.


1. First, log on using Windows Authentication

2. Right-click "server" and select "properties"

3. Find "security" on the left side, which contains a Windows logon identity and "SQL Server and Windows Authentication". Select the second one.

4. Restart the SQLSERVER service. (Right-click the "server", that is, the root node, and choose Restart Server.

 

After my analysis, the reason why the local administrator cannot log on is that after the computer name is changed, the SID of the current local administrator is no longer the SID of the previous local administrator, in SQL Server, SID is actually stored, not the user name, so he cannot log on to the Server. The SA account cannot be used for logon because the organizer did not enable the hybrid authentication mode when preparing the environment.

 

I have encountered a similar problem before, but I suddenly forgot how to solve it. In any case, we still try to solve this problem and refer to the following blog article.

Bytes

 

The general steps are as follows:

Log on as a local administrator and stop the SQL Server service.
Modify the startup parameters of the SQL Server service and add ";-m" (do not include double quotation marks) after the original startup parameters. This sets the SQL Server to the single-user mode.
Start the SQL Server service and use sqlcmd to log on to the SQL Server.
Execute exec sp_addsvrrolemember 'machinenameadministrator 'sysadmin'; GO; (note that the red part should be replaced with your local administrator account)
Stop the SQL Server Service and delete the previously added startup parameter ";-m".
Start the SQL Server Service
We recommend that you set the mixed authentication mode and SA password when installing SQL Server, and then protect the password.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.