PDA

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



TuấnDương
11-03-2011, 06:52 PM
Khi bạn kết nối đến SQL Server 2008 mà gặp phải các lỗi sau:
[Only registered and activated users can see links]

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)

[Only registered and activated users can see links]

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)

[Only registered and activated users can see links]

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

[Only registered and activated users can see links]

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
[Only registered and activated users can see links]

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.
[Only registered and activated users can see links]

B4: Bạn chuyển tiếp qua Tab Service thay đổi Start Mode là Automatic, sau đó Click OK để hoàn tất
[Only registered and activated users can see links]

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
[Only registered and activated users can see links]

B6: Click chuột phải chọn Enable
[Only registered and activated users can see links]

B7: Bạn phải Restart SQL Sevices để thay đổi có hiệu lực.
[Only registered and activated users can see links]

[Only registered and activated users can see links]

B8: Mở SQL Server Management Studio và connect vào SQL Server
[Only registered and activated users can see links]

B9: Click chuột phải vào SQL Server Instance và chọn Properties
[Only registered and activated users can see links]

B10: Chọn Security --> Chọn SQL Server and Windows Authentication mode --> OK
[Only registered and activated users can see links]

B11: Bạn nhận được yêu cầu phải Restart SQL Server
[Only registered and activated users can see links]

B12: Click chuột phải vào SQL Server Instance --> Chọn Restart
[Only registered and activated users can see links]

B13: Bạn đã cấu hình cho SQL Server 2008 kết nối từ xa thành công.

rongxanh_28
26-06-2013, 08:51 AM
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