14

I am in the process of evaluating CouchDB for a specific requirement and I am new to CouchDB.

I have installed Couch DB using the package installation and it has started at the time of installation and listening to port 5984.

Now i want to stop and restart. I have tried various options but none of them worked.

Option 1

sudo service couchdb stop (this does not stop at all)

sudo netstat -lpn shows that a process listening to 5984

Option 2

sudo -i -u couchdb /etc/init.d/couchdb start

This is prompting for the password (ofcourse) which i do not know.

I understand that a new user called couchdb is created at the time of installation. What is the default password of this user?

Manikandan Kannan
  • 8,684
  • 15
  • 44
  • 65
  • Even the following command does not work "ps -U couchdb -o pid= | xargs kill -9" Strangely these work "reboot sudo /etc/init.d/couchdb stop" The out put from ps -ef suggested to restart the server using "sudo /etc/init.d/couchdb stop" but again cannot stop without reboot. I am surprised why stopping the server is a mystery and its not documented well enough. – Manikandan Kannan Jan 09 '13 at 13:51
  • Which version of CouchDB did you install? AFAIK, the default installed one is 1.1, is this the one that you installed? Doing it as `root` (using sudo) should stop it no matter it has been initiated by another user. – OnaBai Jan 09 '13 at 15:45
  • I did a package installation on ubuntu 12.0.4 LTS and i see Couch 1.0.1 got installed. Sudo is prompting me for a password. – Manikandan Kannan Jan 10 '13 at 02:31
  • 1
    When you run `sudo` the password that it prompts for is your own password. – OnaBai Jan 10 '13 at 08:22
  • Let me make it clear. I was talking about option 2 where it prompts for the couchdb passowrd. With Option 1, it really does not stop the server. It says "* Stopping database server couchdb [ OK ]", but "sudo netstat -lpn" shows that the server is still running. – Manikandan Kannan Jan 10 '13 at 09:05
  • Since I'm not having the same problem, lets see how I can help you. 1. While running couchdb, who is the user that runs the server, is `couchdb` or `root`? 2. If you do `sudo -s` you change to `root`, then you can change the password to `couchdb` user and set whichever you want (use `passwd couchdb`). 3. Check if as `couchdb` user you can stop the service. **BTW** did you realize than in option 2 you say `start` and not `stop`. – OnaBai Jan 10 '13 at 09:13
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/22505/discussion-between-onabai-and-manikandankannan) – OnaBai Jan 10 '13 at 09:19

4 Answers4

13

First, you simply need to reboot Ubuntu. If CouchDB is running after an install, it is, so far as I can tell, impossible to kill it. Once you reboot, you can use
sudo service couchdb stop
and then
sudo service couchdb start.

Second, there is no password when CouchDB is first installed, so I believe the fact that it prompts you is a bug. You can go to

http://localhost:5984/_utils 

and then click on the "Fix this" link in the bottom right corner of the screen, where it says "Admin party", to set the first password.

See CouchDB: The Definitive Guide for more info.

brush51
  • 5,691
  • 6
  • 39
  • 73
dnuttle
  • 3,810
  • 2
  • 19
  • 19
  • 5
    Is I was young, they' said "There are only 2 reasons for rebooting Linux: installing net not P&P hardware and installing new kernel". Did it change meanwhile? In any case for me rebooting is not an option, as other services also run on my server. – Valentin H Feb 26 '14 at 10:44
9

I was having this same problem, and found this in the CouchDB docs: To restart the server you must do a POST to the special URL <server>/_restart while authenticated as an admin user.

Example with curl:

curl -X POST http://localhost:5984/_restart -H"Content-Type: application/json"

NOTE: This method is no longer supported in CouchDB 2.0+

Bdoserror
  • 1,184
  • 9
  • 22
1

I think you must do this as root. The rc script will switch as appropriate to the couch user

Tyndyll
  • 334
  • 3
  • 5
  • It really does not stop the server.It says "* Stopping database server couchdb [ OK ]", but "sudo netstat -lpn" shows that the server is still running. – Manikandan Kannan Jan 10 '13 at 06:36
0

I created a new user in the /opt/couchdb/etc/local.ini file

[admins]
;admin = mysecretpassword
myNewUsername = myNewPassword

I then rebooted Ubuntu, once back in Ubuntu I ran:

sudo service couchdb stop
sudo service couchdb start  

I then logged in couchdb using:

http://localhost:5984/_utils/index.html#login

I logged in with mynewusername and mynewpassword and then ran verify installation on:

http://localhost:5984/_utils/index.html#/verifyinstall 

It then worked, but then the password in the local.ini was not encrypted after I restarted ubuntu. But it was encrypted in the:

http://localhost:5984/_utils/index.html#_config/couchdb@127.0.0.1 

I was expecting it would be encrypted in the file

MosesK
  • 359
  • 3
  • 7