简体   繁体   中英

Changing User's Password In SQL Server 2012

I installed Microsoft SQL server 2012. I open Microsoft SQL server management and login with Windows Authentication. I don't know the default password of "sa". So, I need to change it. I follow steps from the answer to this question: Unable to change the password of "sa" in SQL Server 2008 but the password doesn't change!

For better sense see these screenshots in order:
1. I select logins. After, I select "sa". Then, select "Properties".

在此处输入图片说明


2. As you can see, the length of the password is 15 chars.

在此处输入图片说明


3. I change it to "1234". (the length of the password logically will equal to 4 chars) And then select "OK"

在此处输入图片说明


  1. I tried login with SQL Server Authentication在此处输入图片说明 But I cannot login to the system. 在此处输入图片说明

Do you have any idea about this strange problem?

Some Unsuccessful Tries

  • I have tried other passwords with complex char likes "@#FGHbnm1234567890"
  • I changed the mode of authentication with this link Options to Change SQL Server to Mixed Mode Authentication
  • I have reinstalled the SQL server.
  • I have created a new user. But the password of the new user isn't changeable likes "sa"

UPDATE
The first I said length of the password isn't correct. But I have noticed the length of the password isn't real length for the security aspect. I edit step 4 with a better reason for my claim

UPDATE 2
I open logs: 在此处输入图片说明 It seems my authentication mode is wrong:

Login failed for user 'sa'. Reason: An attempt to login using SQL authentication failed. The server is configured for Windows authentication only. [CLIENT: ]

But I change authentication mode before:

SQL Server and windows Authentication mode

在此处输入图片说明

UPDATE 3
Finally, my problem was solved! The reason for my problem is wrong changing authentication mode. The answer of Larnu is a good solution. Also, I suggest this link for step by step guide: How To Enable SQL Server Authentication

The real problem here is that you have your server configured in Windows authentication only. You cannot connect to an instance using SQL Authentication if it's in Windows Authentication only mode, because (to state the obvious) SQL Authentication is not Windows Authentication.

You need to change the authentication mode of the server:

Enable sa login

You can enable the sa login with SSMS or T-SQL.

Use SSMS

  1. In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties.
  2. On the General page, you might have to create and confirm a password for the sa login.
  3. On the Status page, in the Login section, click Enabled, and then click OK.

Using Transact-SQL

The following example enables the sa login and sets a new password. Replace with a strong password before you run it.

 ALTER LOGIN sa ENABLE ; GO ALTER LOGIN sa WITH PASSWORD = '<enterStrongPasswordHere>' ; GO

Change authentication mode (T-SQL)

The following example changes Server Authentication from mixed mode (Windows + SQL) to Windows only.

Caution

The following example uses an extended stored procedure to modify the server registry. Serious problems might occur if you modify the registry incorrectly. These problems might require you to reinstall the operating system. Microsoft cannot > guarantee that these problems can be resolved. Modify the registry at your own risk.

 USE [master] GO EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\\Microsoft\\MSSQLServer\\MSSQLServer', N'LoginMode', REG_DWORD, 1 GO

For mixed authentication, the final parameter would be 2 , not 1 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM