MongoDB Learn One Of The Most Popular NoSQL Databases Derek Rangel Derek Rangel Copyright 2015 All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the author, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. Table of Contents Disclaimer While all attempts have been made to verify the information provided in this book, the author does assume any responsibility for errors, omissions, or contrary interpretations of the subject matter contained within. The information provided in this book is for educational and entertainment purposes only. The reader is responsible for his or her own actions and the author does not accept any responsibilities for any liabilities or damages, real or perceived, resulting from the use of this information. The trademarks that are used are without any consent, and the publication of the trademark is without permission or backing by the trademark owner.
All trademarks and brands within this book are for clarifying purposes only and are the owned by the owners themselves, not affiliated with this document. Introduction MongoDB is one of the leading NoSQL (Non Structured Query Language) databases in use today. It can be used for various purposes, as well as for linking with programming languages while developing our applications. This is why you need to know how to operate MongoDB. This book will guide you in this. Chapter 1- Definition MongoDB is one of the leading NoSQL databases.
It is an open-source and document database which was written in the C++ programming language. It is used for the development of relational databases since it provides us with a traditional table approach to development of the database. Its schemas are well known for the dynamism that they offer, making the integration of data in particular types of application much faster and easier. MongoDB is a cross-platform database, and it offers a high availability, performance, and scalability and this is why it is liked by most database developers. The software is open-source, meaning that you can download and use it for free. In this book, we will explore the features of the database, and some of the functionalities that it offers.
Chapter 2- Environmental Setup Installation of MongoDB in Windows If you need to install MongoDB in your Windows platform, begin by downloading it from its respective site < https://www.mongodb.org/>. Make sure that you have downloaded its latest version and the right version for the operating system that you are using and the processor architecture. If you need to know the version of the Windows OS that you are using, just open the command prompt and then execute the following command: In my case, I get the following regarding the architecture of my system: If you are using a 32 bit version of the Windows OS, then the system can only support a database not larger than 2GB in size, and this is only suitable for evaluation and testing purposes. Once the download process has completed, identify a suitable directory and extract the download in it. The name of the folder where the extraction has been done should be MongoDB-win32-i386-[version]. It can also be MongoDB-win32-x86_64-[version}\, where the version is the version of the MongoDB that you have downloaded.
Once the extraction has been done, open the command prompt, and then run the command shown below: If you had done the extracting of the MongoDB in another directory, navigate to the directory, and then execute the command given above. For the purpose of storage of files, MongoDB requires a folder. The default location of this folder is c:\data\db. This means that you have to manually create this folder by executing the command given below: In case the installation of the MongoDB was done in any other directory, then the alternative path to the folder \data\db needs to be specified . Once you are done with the above step, open the command prompt, and then navigate to the bin folder located in the directory where the MongoDB has been installed. Use the cd command so as to navigate to this folder.
The following commands can be used for this purpose: When you see the message waiting for connections on the screen, just know that your MongoDB is successfully running. The database is now ready to be run. You just have to open the command prompt and then execute the following command: In my case, the above command gives me the following output: The output clearly shows that the MongoDB was successfully installed into the system. You have now learned how to successfully install the database into the Windows operating system. Installation of MongoDB in Ubuntu You need to begin by importing the public GPG encryption key for MongoDB. This can be done by executing the command given below: You then have to create a file named /etc/apt/sources.list.d/MongoDB.list by use of the following command: You can then use the following command so as to update the repository: Once the update has been completed, you can install the MongoDB by use of the following command: In my case above, I have installed the latest version of MongoDB which is on the market.
Make sure that in your case, the latest version of the MongoDB has been installed. The installation of MongoDB should run successfully. Once it is completed, you have to start the MongoDB. This can be done by use of the following command: To stop the MongoDB from running, just use the following command: If you need to restart the database, just run the command given below: To use the MongoDB, execute the following command:
Next page