In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to install and use MongoDB database", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to install and use MongoDB database" this article.
1. Introduction
MongoDB is written in C++ language and is an open source database system based on distributed file storage. Designed to provide scalable high-performance data storage solutions for WEB applications.
In the case of high load, adding more nodes (distributed) can ensure server performance.
MongoDB is a product between relational database and non-relational database, which is the most functional and most like relational database in non-relational database.
2. MongoDB data structure
MongoDB supports a very loose data structure in an bson format similar to json, so you can store more complex data types. MongoDB stores the data as a document, and the data structure consists of key-value (Key= > value) pairs. Field values can contain other documents, arrays, and document arrays. For example:
3. The characteristics of MongoDB
MongoDB is document-oriented and easy to operate.
You can set the index of any property in the MongoDB record (such as FirstName= "Sameer", Address= "8 Gandhi Road") to achieve faster sorting.
You can create data mirrors locally or on the network, which makes MongoDB more scalable.
If the load increases (more storage space and more processing power are needed), it can be distributed among other nodes in the computer network. This is called fragmentation.
Mongo supports a rich set of query expressions. Query instructions use tags in the form of JSON to easily query objects and arrays embedded in a document.
MongoDb uses the update () command to replace the complete document (data) or some specified data fields.
Map/reduce in Mongodb is mainly used for batch processing and aggregation of data.
Map and Reduce. The Map function calls emit (key,value) to traverse all the records in the collection, passing key and value to the Reduce function for processing.
The Map and Reduce functions are written in Javascript, and you can perform MapReduce operations through db.runCommand or mapreduce commands.
GridFS is a built-in feature in MongoDB that can be used to store a large number of small files.
MongoDB allows scripts to be executed on the server. You can write a function in Javascript and execute it directly on the server, or you can store the definition of the function on the server and call it directly next time.
MongoDB supports a variety of programming languages, such as RUBY,PYTHON,JAVA,C++,PHP,C#.
MongoDB is easy to install.
4. Install MongoDB database on Windows platform
Download the MongoDB installation file
MongoDB provides precompiled binary packages for 32-bit and 64-bit systems. Installation files can be downloaded directly from MongoDB's official website:
Https://www.mongodb.com/download-center#community
Note: on 32-bit operating systems, the maximum database for MongoDB is 2GB.
Step 1: select and double-click the installation file, and select "next" to install:
Step 2: select "agree" and click "Next" to proceed to the next step:
Step 3: select the Custom option to customize the installation path, and click "Next":
Step 4: select the installation disk and install it. Here, choose to install to the D:\ MongoDB directory:
Step 5: click the "Install" button to install:
Step 6: click the "Finish" button to complete the installation:
Step 7: create the location where the database files are stored
The folder where the database files are stored must be created before starting the MongoDB service, otherwise the command will not be created automatically and will not start successfully. Here, store the database files in the: d:\ MongoDB\ data\ dbFile directory.
Step 8: check whether the port is occupied
MongoDB uses port 27017 by default, and you can check whether the port is occupied by browsing the web or using the Telnet command.
8.1. The form of browsing the web
Enter: localhost:27017 in the address bar of the browser to view. If the following occurs, the port is normal:
8.2. Use the Telnet command
Enter: telnet 127.0.0.1 27017 in the command line window
Then enter directly, and the situation shown below indicates that the port is normal:
Step 9: create a log file
Create a new folder log (for log files) and a new file mongodb.log under D:\ MongoDB\ data. Create a new mongo.config configuration file in the D:\ MongoDB directory with the following contents:
Step 10: set mongo to Windows service so that it starts automatically every time you boot:
From the command line, go to the bin directory and execute the following command: mongod-- config D:\ MongoDB\ mongo.config-- install-- serviceName "MongoDB"
Note: if it is an operating system above win7, you need to open the command line as an administrator, and then execute the above command, otherwise an error of insufficient permissions will be reported. If the installation is not successful, you can view the created log file, which will record the installation error message.
Step 11: view the service
Enter the services.msc command in the run to open the service directly, and then you can see the MongoDB service just installed in the service. Sometimes you may need to start the service manually:
Click launch in the upper left corner to start the MongoDB service, so that every time you boot, MongoDB will start automatically.
After the MongoDB service starts, find the executable file D:\ MongoDB\ bin\ mongo.exe, double-click the file, and the following interface appears, and you can use mongodb:
Enter the show dbs command to view the currently created database:
Admin and local databases are installed by default.
The above is all the contents of the article "how to install and use MongoDB Database". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.