MongoDB installation
- Download from official website:
https://www.mongodb.com/download-center/community
----Introductionhttps://www.cnblogs.com/dreamsqin/p/10885038.html
- Install to the MongoDB directory of Disk D, and configure D:\MongoDB\bin to the environment variable path
- Create data and log folders under MongoDB
- Test whether MongDB is installed successfully
-Open the cmd command line
-Enter the D:\MongoDB\bin directory
-Enter the following command to start the mongodb service: mongod --dbpath D:\MongoDB\data
-Enter http://localhost:27017 in the browser (27017 is the port number of mongodb) Check, if the display is as follows, it means the connection is successful. If unsuccessful, you can check whether the port is occupied
-Ctrl+C to exit the database
Configure the local windows MongoDB service (after configuration, it can be set to start automatically after booting, you can directly start and shut down manually, and you can start it through the command line net start MongoDB.)
-
Create a configuration file mongo.config under the path D:\MongoDB
# mongod.conf # for documentation of all options, see: # http://docs.mongodb.org/manual/reference/configuration-options/ # Where and how to store data. storage: dbPath: D:\MongoDB\data journal: enabled: true # engine: # mmapv1: # wiredTiger: # where to write logging data. systemLog: destination: file logAppend: true path: D:\MongoDB\log\mongo.log # network interfaces net: port: 27017 bindIp: 127.0.0.1 #processManagement: #security: #operationProfiling: #replication: #sharding: ## Enterprise-Only Options: #auditLog: #snmp: #mp:
-
Open cmd as an administrator, and cd to the D:\MongoDB\bin directory
-
Input: mongod --config "D:\MongoDB\mongo.config" --install --serviceName "MongoDB", that is, install the service according to the mongo.config configuration file just created, and the name is MongoDB.
-
net start MongoDB
Start ornet stop MongoDB
shut down the MongoDB service through the command line .
MongoDB command statement (basic)
- If the service is configured according to the above, only need to start the service
net start MongoDB
mongo
----Connect to mongo databaseshow dbs
----View the databaseuse project
,db.dropDatabase()
----Delete the database named projectuse project
,db.createCollection('users')
----Create usersshow collections
----View the users just createddb.users.insert({name:'zhangsan'})
----Insert data to usersdb.users.find()
----View users data