How to rename a CouchDB database?
I am using couchdb 2, i assume the previous answers are for an older version because the database files are not listed in the /var/lib/couchdb folder found using 'couch-config --db-dir' command.
the simplest way i am following is to use futon and replicate the db you want to rename to a new desired name then delete the old database.
If you have access to the database file itself, (located in /var/lib/couchdb
depending on your installation) you can simply rename it.
To my knowledge, that will effectively "rename" the database. I would make sure the server is not running when you perform this operation, just in case.
Adding to what Dominic and PPPaul said...
Renaming the file is absolutely the way to go (make sure you rename it as the same user, not accidentally change the ownership to root
or something).
This is perfectly safe to do in a full running production environment, yes. One of the many advantages of an HTTP/REST API is that there are no adapters with stateful connections to the DB. Each request is a new request. So basically the first request to CouchDB after the rename is complete will be able to use the new name.
But wait, there's more!
One really cool thing is that even after the rename, the CouchDB server still has an open file-handle to the file itself (which isn't affected by renaming the inode), so until the CouchDB server is actually restarted you'll still be able to access the DB using the old name too.
Update
Great observation by ATfPT in the comments, apparently the DB name needs to start with a lower case letter, otherwise it doesn't show up in Futon.
Update
Another thing I remembered: to find out where the DB files are, run this: couch-config --db-dir