Ý kiến phản hồi sẽ được gửi đến mdtq.vn: Bằng cách nhấn nút gửi, ý kiến phản hồi của bạn sẽ được sử dụng để cải thiện các sản phẩm và dịch vụ của mdtq.vn. Chính sách về quyền riêng tư.

Bạn đang xem: Đổi mật khẩu sa trong sql server 2008


Trong bài viết này

Applies to:

*
SQL Server (all supported versions)

This topic describes how to change the server authentication mode in SQL Server by using SQL Server Management Studio or Transact-SQL. During installation, SQL Server Database Engine is set to either Windows Authentication mode or SQL Server and Windows Authentication mode. After installation, you can change the authentication mode at any time.

If Windows Authentication mode is selected during installation, the sa login is disabled and a password is assigned by setup. If you later change authentication mode to SQL Server and Windows Authentication mode, the sa login remains disabled. To use the sa login, use the ALTER LOGIN statement to enable the sa login and assign a new password. The sa login can only connect to the server by using SQL Server Authentication.

Before you begin

The sa account is a well known SQL Server account and it is often targeted by malicious users. Do not enable the sa account unless your application requires it. It is important that you use a strong password for the sa login.

Change authentication mode with SSMS

In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.

On the Security page, under Server authentication, select the new server authentication mode, and then click OK.

In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.

In Object Explorer, right-click your server, and then click Restart. If SQL Server Agent is running, it must also be restarted.

Xem thêm: Ứng Dụng Quay Màn Hình Ios, Cách Quay Màn Hình Iphone Và Ghi Âm Dễ Ơi Là Dễ

Enable sa login

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

Use SSMS

In Object Explorer, expand Security, expand Logins, right-click sa, and then click Properties.

On the General page, you might have to create and confirm a password for the sa login.

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 = "" ; 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. mdtq.vn cannot guarantee that these problems can be resolved. Modify the registry at your own risk.


USE GOEXEC xp_instance_regwrite N"HKEY_LOCAL_MACHINE", N"Software\mdtq.vn\MSSQLServer\MSSQLServer", N"LoginMode", REG_DWORD, 1GO