[MS SQL Sever] Kích hoạt Remote Connection cho SQL Server 2005 / 2008

TuấnDương

Admin
Thành viên BQT
Khi bạn kết nối đến SQL Server 2008 mà gặp phải các lỗi sau:
1.png


Cannot connect to SQL-Server-Instance-Name
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 28 – Server doesn’t support requested protocol) (Microsoft SQL Server)

2.png


Cannot connect to SQL-Server-Instance-Name
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) (Microsoft SQL Server)

3.png


Cannot connect to SQL-Server-Instance-Name
Login failed for user ‘username‘. (Microsoft SQL Server, Error: 18456)
Đó chính là bạn chưa kích hoạt Remote Connection cho SQL Server. Để kích hoạt, bạn làm theo các bước sau:
1. Hãy bật SQL Server Browser Service lên nếu bạn chưa bật. SQL Server Browser sẽ "lắng nghe" các incoming request từ Client.
2. Hãy Enable TCP/IP Protocol cho SQL Server 2008 để chấp nhận Remote Connection.
3. Thay đổi Server Authentication thành SQL Server and Windows Authentication, bởi mặc định SQL Server 2008 chỉ cho phép bạn để ở chế độ Windows Authentication trong khi đó nếu bạn muốn dùng Remote Connection thì bạn phải để là SQL Server Authentication.
B1: Mở SQL Server Config Manager: Start --> Program --> Microsoft SQL Server 2008 --> Configuration Tools --> SQL Server Configuration Manager

4.png


B2: Trên SQL Server Configuration Manager chọn SQL Server Services --> Chọn SQL Server Browser & Start nó nếu bạn đang Stop còn không hãy làm tiếp B3
5.png


B3: Click chuột đúp vào SQL Server Browser để xem Properties chọn account để Start SQL Server Browser Service ở đây tôi để là Local Service account.
6.png


B4: Bạn chuyển tiếp qua Tab Service thay đổi Start Mode là Automatic, sau đó Click OK để hoàn tất
7.png


B5: Bên Panel bên trái, Expand SQL Server Network Configuration --> chọn Protocols for SQLEXPRESS bạn có thể thấy ngay là Protocol TCP/IP đang bị Disabled
9.png


B6: Click chuột phải chọn Enable
10.png


B7: Bạn phải Restart SQL Sevices để thay đổi có hiệu lực.
11.png


12.png


B8: Mở SQL Server Management Studio và connect vào SQL Server
13.png


B9: Click chuột phải vào SQL Server Instance và chọn Properties
14.png


B10: Chọn Security --> Chọn SQL Server and Windows Authentication mode --> OK
15.png


B11: Bạn nhận được yêu cầu phải Restart SQL Server
16.png


B12: Click chuột phải vào SQL Server Instance --> Chọn Restart
17.png


B13: Bạn đã cấu hình cho SQL Server 2008 kết nối từ xa thành công.
 
BoNus nếu làm như trên vẫn chưa điều khiển kết nối đc SQL từ xa, ví dụ cơ bản là làm web MU online khi chạy query nó ghi là không thể kết nối đến MSSQL???
Ta có thể thêm bước sau:
Vào start > SQL Sever Configuration Manager > SQL sever 2005 Network configuration > Protocols MSSQL SEVER > chuột phải vào TCP/IP chọn properties
Ở thanh IP addresses thuộc tính enabled ta để yes ở IP ::1 và 127.0.0.1 nhé.
Chúc thành công
 
Back
Top