Couchbase 默认创建的 bucket(桶)是没有密码的,那么在 web.config 里面的连接字符串是这样的
<!--配置缓存开始--> <configSections> <section name="couchbase" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/> </configSections> <couchbase> <servers bucket="default" bucketPassword=""> <add uri="http://127.0.0.1:8091/pools"/> <!--<add uri="http://192.168.0.3:8091/pools"/>--> </servers> </couchbase> <!--配置缓存结束-->
但是这样,好像是任何客户端,都可以连接上你的bucket(桶),感觉不是很好,那么我们如何给couchbase来设置连接密码呢?
答案就是我们自己创建一个bucket,然后给他加上密码就可以了
或者如果你已经创建了,那么还可以修改密码
最后web.config就是下面所示了
<configuration> <configSections> <section name="couchbase" type="Couchbase.Configuration.CouchbaseClientSection, Couchbase"/> </configSections> <couchbase> <servers bucket="notdefault" bucketPassword="mima"> <add uri="http://127.0.0.1:8091/pools"/> </servers> </couchbase>