Recover Couchbase password without knowing it

2019-07-09 09:01发布

I'm working on a mac, downloaded the community edition for mac. Launched the app, and opened the admin console. So far so good, untill I logged out. Now I can't log in again since I've never had to set the password in the first place. It might have been set on a previous version a whole while back, but I'm not sure.

Reinstalling it doesn't work. I keep getting bounced back to the login screen.

Executing the following command as suggested in other posts and help online results in a crash of erlang

erl -noinput -eval 'case file:read_file("/Users/testuser/Couchbase Server.app/Contents/Resources/couchbase-core/var/lib/couchbase/config/config.dat") of {ok, B} -> io:format("~p~n", [binary_to_term(B)]) end.' -run init stop | grep cred

Crash dump was written to: erl_crash.dump
init terminating in do_boot ()

Any suggestions are welcome

I've been trying to put a new user in the admins section of the couchdb ini files, but they don't seem to take hold (password doesn't get hashed, which it should when these files are read)

4条回答
何必那么认真
2楼-- · 2019-07-09 09:36

In case it wasn't clear since it was not fully explained in the previous answer and I'm not allowed to comment just yet. The cbreset_password script is a Python script.

For Mac OS, make sure you have Python installed. Also, there are 2 required pieces of information, the IP address of the Couchbase instance you're trying to reset and the port number. So for a local installation, with a standard Couchbase port of 8091, the command would look something like this:

python /Applications/Couchbase\ Server.app/Contents/Resources/couchbase-core/bin/cbreset_password 127.0.0.1:8091
查看更多
小情绪 Triste *
3楼-- · 2019-07-09 09:39

Password is saved in plain text in config.dat binary file that located in \var\lib\couchbase folder.

You can search for string "username" and then next to it you will see "password" field and plain text value of the password.

I think there is an open defect to have better password storage mechanism in place.

The password can be changed using the couchbase-cli tool.

shell> ./couchbase-cli cluster-init -c 127.0.0.1:8091 --user=[CURRENT_USERNAME] --password=[CURRENT_PASSWORD] --cluster-init-username=[NEW_USERNAME] --cluster-init-password=[NEW_PASSWORD]

查看更多
Animai°情兽
4楼-- · 2019-07-09 09:39

On mac you can do the follwing steps

sudo ln -s $CB_HOME/Couchbase\ Server.app/Contents/Resources/couchbase-core/lib/ /lib
cd "$CB_HOME/Couchbase Server.app/Contents/Resources/couchbase-core/bin"
./erl -noinput -eval 'case file:read_file("[PATH TO DATA]/Library/Application Support/Couchbase/var/lib/couchbase/config/config.dat") of {ok, B} -> io:format("~p~n", [binary_to_term(B)]) end.' -run init stop | grep creds

CB_HOME is pointing to your Couchbase installation directory

查看更多
放我归山
5楼-- · 2019-07-09 09:42

There is a cbreset_password script you can run, located in the /Contents/Resources/couchbase-core/bin folder of you CouchBase server App

So for me it was in /Applications/Couchbase Server.app/Contents/Resources/couchbase-core/bin

Simply run it and you will be able to reset the password for the Administrator account

查看更多
登录 后发表回答