1、在Ubuntu 18.04.1 LTS上安装CouchDB
参考:http://docs.couchdb.org/en/latest/install/unix.html
$ echo "deb https://apache.bintray.com/couchdb-deb bionic main" \
| sudo tee -a /etc/apt/sources.list
这一步是替换sources.list文件中的“系统标识”通配符,如果因为没有完全替换成功而报错尝试手动改过来。
sudo gedit /etc/apt/sources.list
将{distribution}全部替换为bionic(注意,Ubuntu 18.04的“系统标识”是bioinc,其他版本的Ubuntu就不一定了)
$ curl -L https://couchdb.apache.org/repo/bintray-pubkey.asc \
| sudo apt-key add -
$ sudo apt-get update && sudo apt-get install couchdb
安装完成之后,启动和停止的命令如下:
$ sudo systemctl stop couchdb
$ sudo systemctl start couchdb
对于一个已经启动的CouchDB,可以通过如下命令查询到它的基本信息
$ curl localhost:5984
{"couchdb":"Welcome","version":"2.2.0","git_sha":"2a16ec4","features":["pluggable-storage-engines","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
2、最基本的使用
创建和查询数据库
$ curl -X GET http://127.0.0.1:5984/_all_dbs
["_replicator","_users"]
$ curl -X PUT http://127.0.0.1:5984/fuck_test
{"error":"unauthorized","reason":"You are not a server admin."}
$ sudo curl -X PUT http://admin:123456@127.0.0.1:5984/fuck_test
{"ok":true}
$ curl -X GET http://127.0.0.1:5984/_all_dbs
["_replicator","_users","fuck_test"]
删除数据库
$ sudo curl -X DELETE http://admin:123456@127.0.0.1:5984/fuck_test
{"ok":true}
$ curl -X GET http://127.0.0.1:5984/_all_dbs
["_replicator","_users"]
3、使用可视化界面管理CouchDB——Futon
在浏览器输入http://127.0.0.1:5984/_utils/