データベースがmlab.comでホストされており、mongodb C#ドライバを使用して接続しようとしましたが、mlabデータベースに接続しようとすると次の例外が発生します。MongoDB C#認証例外
MongoCommandException:コマンド 'saslStart' failed:認証に失敗しました。 MongoDB.Driver.Operations.CommandOperation`1 [MongoDB.Driver.CommandResult] .Execute(MongoDB.Driver。MongoDB.Driver.CommandResult)このメソッドを使用すると、 MongoDB.Driver.Communication.SecurityAuthenticationProtocol.RunCommand(MongoDB.Driver.Internal.MongoConnection接続、System.Stringデータベース名、IMongoCommandコマンド)MongoDB.Driver.Communication.Security.SaslAuthenticationProtocol.Authenticate(MongoDB.Driver。 Internal.MongoConnection接続、MongoDB.Driver.MongoCredential資格情報)MongoSecurityExceptionとしてリロート:エラー:18 - 認証に失敗しました。 MongoDB.Driver.Communication.Security.SaslAuthenticationProtocol.Authenticate(MongoDB.Driver.Internal.MongoConnection接続、MongoDB.Driver.MongoCredential資格情報)MongoDB.Driver.Communication.Security.Authenticator.Authenticate(MongoDB.Driver.MongoCredential資格情報)MongoDB.Driver .MommoDB.Driver.Internal.MongoConnection.Open()MongoDB.Driver.Internal.MongoConnection.GetNetworkStream()MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoDB.Bson.IO.BsonBufferバッファ、Int32 requestId)MongoConnectionExceptionとしてRethrow:サーバーdsXXXXXX.mlab.com:XXXXXに接続できません:エラー:18 - 認証に失敗しました.. MongoDB.Driver.Internal.DirectMongoServerProxy.Connect(TimeSpanタイムアウト、MongoDB.Driver.ReadPreference readPreference)MongoDB .Driver.MongoServer.Connect(TimeSpan timeout)MongoDB.Driver.MongoServer.Connect()
以下はエラーを投げる行です。
client = new MongoClient (new MongoUrl("mongodb://:@dsxxxxx.mlab.com:xxxxx/mydb"));
とDBユーザーが同様に管理者権限を持っている...ユーザ名とパスワードも
正しいモンゴURI構文に接続している場合は、接続文字列が異なるものになることを
注意です:MongoDBの://ユーザー名:パスワード@ホスト:ポート/ DBNAME。認証を有効にしていない場合は@を渡す必要はありません。代わりにmongodb://dsxxxxx.mlab.com:xxxxx/mydbの代わりに –
** mlab **データベースに移動すると、両方の接続文字列が表示されます。 1つはシェルで、もう1つはドライバで使用する。データベースを作成した後に作成したdbユーザーのユーザー名とパスワードを置き換えてそこからコピー&ペーストできますか? –