在Ubuntu上安装mongodb

参考:https://docs.mongodb.com/v3.0/tutorial/install-mongodb-on-ubuntu/

The MongoDB instance stores its data files in /var/lib/mongodb and its log files in /var/log/mongodb by default, and runs using the mongodb user account. You can specify alternate log and data file directories in /etc/mongod.conf.

启动: sudo service mongod start

重新启动: sudo service mongod restart

命令:

  1. mongo 进入MogonDB shell
  2. show dbs 显示所有的数据库
  3. use somedb 切换到指定的数据库
  4. show collections 显示数据库中的所有collection

查询语法参考:https://docs.mongodb.com/v3.0/core/read-operations-introduction/