This document applies to the installation, configuration, and use of MongoDB 2.0.1 on Windows 2003.
Or download the latest stable version as needed.
Installation: Extract the compressed package after downloading to any directory. This article assumes that it is extracted to the [D:\\mongodb] directory.
Configuration: Create a directory for data directories and log files:
Create a log file:
In the above editor interface, use [alt+f] to call up the [File] menu, select the [Save] item, and then select the [Exit] item to exit the editor. Check whether there is a log.txt file in the log directory. The following steps can be performed. If there is no existing, you can directly create an empty log.txt file on the windows interface.
Starting the mongodb service
Creating mongodb as a windows system service and starting the mongodb service.
Enter mongodb's bin directory, use mongod to create services, pay attention to the directory parameter values.
Create a service
:mongod --install --serviceName mongodb --logpath d:\\mongodb\\data\\log\\log.txt --logappend --dbpath d:\\mongodb\\data\\db --directoryperdb
Parameters: directoryperdb, optional parameters, each database is stored in a separate folder.
Starting Services
:net start mongodb
Use: Log in to native mongodb
After the Mongodb service starts, open the command line tool.
Login: mongo 127.0.0.1:27017
27017 is the default port for mongodb.
Logging in to remote mongodb
Login: mongo 192.168.0.137:27017
27017 is the default port for mongodb
Basic Commands
Display the current database: db
Show all databases: show dbs
Create database: no command to create a database, you can First use [use test1] to switch the database. At this time, the database has not been created. After creating a collection under the database or adding data to the collection, the data [test1] is automatically created.
Switch database: use test
Display database collection: show collections
Create collection: db.createCollection(“users”)
View db Help for the command: db.help()
View help for the collection command: db.collection.help()
Insert data: db.users.save({“name”:&rdquo ;shiwenbin”,”age”:100})
Retrieving data: db.users.find()
Pagination: db.users.find().skip(2).limit (3)
skip, skimming the specified number of bars.
limit, get the specified number of bars.
Command Help: See the help() of any command for the help of any command to see the parameters and usage of this command.
FAQ
Chinese garbled: After inserting Chinese code, it is normal to use code to read it, but to view the inserted Chinese in the command line tool, Show garbled. This is mainly caused by the encoding of the cmd window, because the encoding of the mongodb background is utf-8, which can be solved by modifying the encoding of the cmd window.
1) Open a cmd window, type [chcp 65001]
2) Then open the properties window of the cmd window and select any font other than “ dot matrix font in the font. Font
Many friends find that the previously partitioned disk partition is not reasonable after using the c
Installing Hyper-V in Server Core mode of Windows Server 2008 is cumbersome, and it is much easier t
Todays article introduces you to a new feature about Active Directory: Restartable Active Directory,
to download version 2.0.1. Or download the latest stable version as needed. Installation: Extract
MZD uses win2008 system to do the settings and optimization
3 security solutions for Win2000 remote control
Resolution: Win2008 Server Firewall Settings
Notepad++ 6.0 officially released: improving large file loading performance
Windows Server R2 2008 Chinese Standard Edition 1999 yuan
Windows automatically repairs damaged system files
Adding Window2008DC to the 2003 Domain
Win 2000/XP installation driver compatibility issues
Setting up Windows 2003 System Firewall
Win2003 system security countermeasures
Three tips to achieve efficient management of Windows servers
U disk in Win8 can not stop the "universal volume" five methods
Method of deleting invalid old icons in the Windows 7 notification area
What if the Lenovo Flex touch is not working? Lenovo Flex touch failure solution
Mobile phone Sina Weibo display is very sorry, Weibo has stopped running how to do
Microsoft "Imperial Age OL" terminated development
Microsoft released 14 security updates, Win10 ushered in 4 update patches
What is the process of jusched.exe? How to disable
How to solve the unstable transmission speed of u disk?
Some common data backup methods
XP system account settings and account corresponding permission settings (1)