-->

Bucket password in Couchbase

2020-08-15 10:16发布

问题:

I am creating a demo project for reative programming with springboot and Couchbase. I have set the below properties in application.properties file:

spring.couchbase.bootstrap-hosts=localhost
spring.couchbase.bucket.name=vanquish
spring.couchbase.bucket.password=
spring.data.couchbase.repositories.type=auto

As I don't have any bucket level password while creating it. Still, service is not able to start because of below exception:

Caused by: com.couchbase.client.java.error.InvalidPasswordException: Passwords for bucket "vanquish" do not match.
    at com.couchbase.client.java.CouchbaseAsyncCluster$OpenBucketErrorHandler.call(CouchbaseAsyncCluster.java:651) ~[java-client-2.5.9.jar:na]
    at com.couchbase.client.java.CouchbaseAsyncCluster$OpenBucketErrorHandler.call(CouchbaseAsyncCluster.java:634) ~[java-client-2.5.9.jar:na]
    at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onError(OperatorOnErrorResumeNextViaFunction.java:140) ~[rxjava-1.3.8.jar:1.3.8]
    at rx.internal.operators.OnSubscribeMap$MapSubscriber.onError(OnSubscribeMap.java:88) ~[rxjava-1.3.8.jar:1.3.8]
    at rx.observers.Subscribers$5.onError(Subscribers.java:230) ~[rxjava-1.3.8.jar:1.3.8]
    at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.checkTerminated(OperatorObserveOn.java:273) ~[rxjava-1.3.8.jar:1.3.8]
    at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.call(OperatorObserveOn.java:216) ~[rxjava-1.3.8.jar:1.3.8]
    at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) ~[rxjava-1.3.8.jar:1.3.8]

I tried searching all properties but not able to find any relevant property to set username and password or setting the password in couchbase for the bucket.

回答1:

Assuming that you're using a couchBase version 5.x:

According to the couchBase documentation:

To access cluster-resources, Couchbase Server users — administrators and applications — must specify a username and password.

Steps to follow:

  1. Open your couchBase admin console: http://<couchBase-host>:8091/ui/index.html#!/overview
  2. Click on 'Security'
  3. click on 'Add user'

In the 'Add user' form add these parameters:

User Name: This must be the bucket name, in your case vanquish.

Password: Set the password that you want, this must be the value set in spring.couchbase.bucket.password.

Roles: Go to Roles -> Bucket Roles -> Bucket Admin and select your bucket, in your case vanquish.

Click on 'Save'.

After doing this and set the password in spring.couchbase.bucket.password it should work.