gorm無法連線SQL server 2008(mssql)的解決方法

現象

連線資料庫的時候gorm丟擲錯誤提示:wsarecv: An existing connection was forcibly closed by the remote host.

解決辦法

如果是sql server 2008則安裝sp4更新包
下載地址:SQLServer2008SP4-KB2979596-x64-CHS

如果是sql server 2008 R2則安裝R2 sp3更新包
下載地址:SQLServer2008R2SP3-KB2979597-x64-CHS

注意事項

安裝更新包需要先確定下其他程式是否需要讀取資料庫,這個更新包貌似會改變一些東西。我之前就是因為安裝了更新包導致客戶現有的程式全都不能執行了=_=

出現其他問題請在評論區留言。

6 thoughts on “gorm無法連線SQL server 2008(mssql)的解決方法”

  1. 新增encrypt=DISABLE引數,詳情請了解sql server ssl加密
    db, err := gorm.Open(“mssql”, “sqlserver://username:password@127.0.0.1:1433?database=dbname&encrypt=DISABLE”)

Leave a Reply to An existing connection was forcibly closed by the remote host Cancel reply

Your email address will not be published. Required fields are marked *

Captcha Code