最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

在MongoUri中,如何使用密码处理@?

IT培训 admin 14浏览 0评论

在MongoUri中,如何使用密码处理@?

我的Mongo Uri就是这样。我的密码末尾必须有一个@。然后,Mongo会抛出一个错误,即==授权部分中的转义符号。有没有办法使它起作用?

 const url = 'mongodb://roots:something@@localhost:27017?authMechanism=DEFAULT&authSource=db';
回答如下:

尝试使用此代码来编码用户名和密码:

function percentEncode(string) {
  let encoded = '';
  string.split('').forEach(function(char) {
    encoded += '%' + char.charCodeAt(0).toString(16).toUpperCase();
  });
  return encoded;
}

https://tools.ietf/html/rfc3986#section-2.1

[这里是我的主意:https://github/strongloop/loopback-connector-mongodb/issues/499

祝你好运=)

在MongoUri中,如何使用密码处理@?

我的Mongo Uri就是这样。我的密码末尾必须有一个@。然后,Mongo会抛出一个错误,即==授权部分中的转义符号。有没有办法使它起作用?

 const url = 'mongodb://roots:something@@localhost:27017?authMechanism=DEFAULT&authSource=db';
回答如下:

尝试使用此代码来编码用户名和密码:

function percentEncode(string) {
  let encoded = '';
  string.split('').forEach(function(char) {
    encoded += '%' + char.charCodeAt(0).toString(16).toUpperCase();
  });
  return encoded;
}

https://tools.ietf/html/rfc3986#section-2.1

[这里是我的主意:https://github/strongloop/loopback-connector-mongodb/issues/499

祝你好运=)

发布评论

评论列表 (0)

  1. 暂无评论