Recover Couchbase password without knowing it

匆匆过客 提交于 2019-12-13 16:29:18

问题


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)


回答1:


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




回答2:


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]




回答3:


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




回答4:


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


来源:https://stackoverflow.com/questions/16148207/recover-couchbase-password-without-knowing-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!