Posts

Showing posts from February, 2017

Storing and retrieving data with MongoDB

Image
Storing and retrieving data with MongoDB >  show dbs local 0.03125GB test (empty) > show collections startup_log system.indexes users > db.createCollection('users') >db.users.insert({'name':'root','uid':'0001'}) >db.users.find() { "_id" : ObjectId("58b334b1f4d36fb19595a7a9"), "name" : "root", "uid" : "0001" } In this recipe, we  will look at basic CRUD operations with  MongoDB. We will learn how to create  databases, store, retrieve, and update stored data. This is a  recipe to get started with MongoDB. Getting ready Make sure that you have installed and configured MongoDB. You can also use the MongoDB installation on a remote server. How to do it… Follow these steps to store and retrieve data with MongoDB: Open a shell to interact with the Mongo server: $ mongo To open a  shell on a remote serv er, use t

awk $1>10 -F '{print $1, $NR}'

awk -F ' '  '$5>30 {print $5}' file3 0 6 87 4096 29 400 0 4096 awk -F ' '  '/4096/ {print $5}' file3 4096 4096 $NF last field awk '{print $1,$NF}' file3 total 24 -rw-rw-r-- .hiddenfile -rw-rw-r-- testfile1 -rw-rw-r-- sc2 awk '$5>500' file3 drwxr-xr-x 45 ubuntu2 ubuntu2 4096 Feb 26 07:21 .. drwxrwxr-x  2 ubuntu2 ubuntu2 4096 Feb 26 10:55 .

Installing MongoDB [NOT STARTED]

Installing MongoDB Until now, we have  worked with the relational database server, MySQL. In this recipe, we will learn how to install and configure MongoDB, which is a not only SQL (NoSQL)  document  storage server. Getting ready You will need access to a root account or an account with  sudo  privileges. How to do it… To get the latest version of MongoDB, we need to add the MongoDB source to Ubuntu installation sources: First, import the MongoDB GPG public key: $ sudo apt-key adv \ --keyserver hkp://keyserver.ubuntu.com:80 \ --recv 7F0CEB10 Create a  list  file and add an install source to it: $ echo “deb http://repo.mongodb.org/apt/ubuntu “$(lsb_release -sc)”/mongodb-org/3.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list Update the  apt  repository sources and install the MongoDB server: $ sudo apt-get update $ sudo apt-get install -y mongodb-org sudo apt-get install -y mongodb After installation completes,