Install and Use CouchDB on Ubuntu 16.04

Leave your reply

Introduction

CouchDB is an open source NOSQL database solution which uses the intuitive JSON format and HTTP protocol. CouchDB is able to reliably scale for any size project, and can be replicated across a wide variety of computing environments, from large-scale cloud server clusters to mobile devices. Learn how to install and use CouchDB on a Servidor Cloud with Ubuntu 16.04.

Requirements

  • A Servidor Cloud with Ubuntu 16.04

Install CouchDB

Update the package list:

sudo apt update

Add the PPA repository:

Add the CouchDB PPA repository:

sudo add-apt-repository ppa:couchdb/stable

Update the package list once more:

sudo apt update

Then install CouchDB with the command:

sudo apt install couchdb

Use curl to verify that CouchDB is installed and running:

curl localhost:5984

The server will respond with a welcome message:

{"couchdb":"Welcome","uuid":"266009d1980fbda93d96cd3bd95c2e81","version":"1.6.1","vendor":{"version":"16.04","name":"Ubuntu"}}

Use CouchDB

CouchDB uses a basic HTTP interface, and returns JSON objects. You can use the curl utility from the command line to communicate with CouchDB, as seen in the example above.

The command to view a list of databases is:

curl localhost:5984/_all_dbs

The server will return a JSON reply to the command line:

user@localhost:~# curl localhost:5984/_all_dbs
["_replicator","_users"]

The curl command uses the GET method by default. To send CouchDB a request with a different method, use the -X flag to override the default method, and specify the method you wish to use instead:

curl -X PUT localhost:5984/[etc.]

For example, you will use the PUT method to create a database. The command to create a database named reviews is:

curl -X PUT http://127.0.0.1:5984/reviews

The server will confirm the creation:

{"ok":true}

You will also see the reviews database in the list of all databases:

root@localhost:~# curl localhost:5984/_all_dbs
["_replicator","_users","reviews"]

You can easily use and manage CouchDB from the command line using the Curl utility. However, CouchDB also comes with a built-in web-based administration interface named Futon. For more information on using Futon, see our article Use Futon to Manage CouchDB.