Unable to execute create index N1QL query?

Hello guys,

I am using Couchbase server 4.1.1. I tried to execute the following command through command line : -

Step 1 :- bin>./cbq -engine="http://my_url@spnpass@127.0.0.1:8093"

Step 2 :- cbq> create primary index on 'my_url';

Response I am getting :-
{ "requestID" : "some random char", "signature" : null, "results" : [ ], "errors" : [ { "code" : 10000, "msg" : "Authorization Failed" } ], "status" : "stopped", "metrics" : { "some key":"value pairs data" } }

FYI :- The credential for Couchbase bucket is absolutely correct.

Update 1 :-
I don’t know what strike to me but I remove the password from the bucket and execute the following command and it works.

Step 1 :- bin>./cbq -engine="http://127.0.0.1:8093"

Step 2 :- cbq> create primary index on 'my_url';

Response I am getting :-

{ "requestID" : "some random char", "signature" : null, "results" : [ ], "status" : "success", "metrics" : { "some key":"value pairs data" } }

Now all I have to do is to supply password again. But it’s not a solution it’s a JUGAAD. :wink:

This is fixed in 4.5. For 4,1, can you invoke cbq twice. Once for the CREATE INDEX, and the second time credentials for your queries. @isha.

Hello @geraldss, this was working fine with 4.1.0 but in 4.1.1 it’s not working.

Yes, that doesn’t surprise me. Some unintended consequence. My apologies.

Hi @Chi

If you refer to the documentation
http://developer.couchbase.com/documentation/server/current/tools/cbq-shell.html#topic_bzd_zwr_w5

See the the --user, --password and --credentials options.

from your above query, it looks like the credentials are bucket credentials. You can use the following for the same

./cbq --credentials=my_url:spnpass http://127.0.0.1:8093

Or, once you are within a cbq session you can set it using the \SET command as follows

cbq > \SET -creds my_url:spnpass;
cbq > create primary …

Thanks
Isha

I think he is on 4.1.

With 4.1 it might be better to pass in administrator credentials instead of explicit bucket credentials. This way you should be able to access all buckets without authorization.

./cbq -engine=“http://Administrator@password@127.0.0.1:8093”

Otherwise you can have 2 separate cbq sessions for the create index and query.

Ideally it’ll be good to upgrade to 4.5.1 since it is easier to handle different scenarios with the new shell. :slight_smile:

Thanks
Isha

This didn’t work for me. It seems it is unable to validate user’s bucket credentials when executing through command line.

It needs an upgrade.

Thanks,
Chi

@Chi
I suggest you download 4.5 and use the new shell instead of the old one. It is much more convenient to use.

Downloading the new version
https://www.couchbase.com/nosql-databases/downloads

About the new shell :

Thanks
Isha

There seems to be a type here
It should be
./cbq -engine=“http://Administrator:password@127.0.0.1:8093

Sorry about that
Thanks
Isha

You’re using the wrong QUOTE around my_url.

  1. You don’t need any quotes.
  2. If you do want to delimit, use BACK-QUOTES. Example: my_url

In my code I used BACK-QUOTES. Here I can’t do so inside Preformatted text. So it’s a substitute to represent what I have done. Anyway it’s bug in 4.1.1 which can’t validate bucket credential when executing through command line. See above for more details.

This works for me…Thank you thank you tank you very much…

1 Like