存档

2017年9月 的存档

身边多了个小朋友

2017年9月29日 没有评论

就让我沐浴在温和的春风里,宛如夏日午后泡开的凉茶,在醉人的秋天里带给你沉甸甸的不一样。

分类: 一句话 标签:

Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1

2017年9月22日 没有评论

最近在写一个数据清洗工具,以调整MongoDB的数据内容。工具使用了MongoDB官方提供的Nuget包,但是在连接的时候,一直无法成功,总是连接超时报Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1异常。

后来在Stackoverflow上找到解决方法,原来问题出在连接字符串上。

原来我的连接字符串是:mongodb://username:password@ip/mydb,就出现 Unable to authenticate using sasl protocol mechanism SCRAM-SHA-1 异常。在官网的文档里有一句话 Above, the database by the name of “mydb” is where the credentials are stored for the application.

原来连接字符串里要写存储授权信息的数据库名称,默认是为admin。所以在连接字符串里不需要提供数据库名称了。在后面可以通过 var db = client.GetDatabase(“dbname”); 来定位到需要操作的数据库上。

 

分类: 一句话, 日常 标签: