第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

MongoDB Atlas 未連接到我的 golang 應用程序

MongoDB Atlas 未連接到我的 golang 應用程序

Go
qq_笑_17 2022-06-01 17:33:56
我是 golang 和 MongoDB 的新手,我一直在關注 mongoDb 的官方博客,開始使用 go 的 mongo-db 驅動程序,但由于某種原因我無法連接到我的 mongodb 這是代碼,錯誤是“超出上下文期限”,thnx提前package mainimport (    "context"    "fmt"    "log"    "time"    "go.mongodb.org/mongo-driver/bson"    "go.mongodb.org/mongo-driver/mongo"    "go.mongodb.org/mongo-driver/mongo/options"    // "go.mongodb.org/mongo-driver/mongo/readpref")func main() {    client, err := mongo.NewClient(options.Client().ApplyURI("mongodb+srv://chandru:<Heregoesmypassword>@cluster0-9jkaf.mongodb.net/test?retryWrites=true&w=majority"))    if err != nil {        log.Fatal(err)    }    ctx, _ := context.WithTimeout(context.Background(), 20*time.Second)    err = client.Connect(ctx)    if err != nil {        log.Fatal(err)    }    defer client.Disconnect(ctx)    databases, err := client.ListDatabaseNames(ctx, bson.M{})    if err != nil {        log.Fatal(err)    }    fmt.Println(databases)}
查看完整描述

1 回答

?
富國滬深

TA貢獻1790條經(jīng)驗 獲得超9個贊

一個可能的原因是您沒有使用 MongoDB Atlas 將您的 IP 列入白名單。請參閱以下指南:https ://docs.atlas.mongodb.com/security-whitelist/#view-whitelist-entries

請記住,如果您從本地計算機連接,您的 IP 地址可能會更改。您可以從 ISP 獲取靜態(tài) IP 地址或通過另一臺計算機連接。

您也可以輸入 0.0.0.0/0 以允許從任何 IP 訪問,但這當然不太安全。


查看完整回答
反對 回復 2022-06-01
  • 1 回答
  • 0 關注
  • 157 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號