First step : Install
#setp 1. Import the public key used by the package management system. sudo apt-key adv--keyserver HKP://keyserver.ubuntu.com:80--recv 0c49f3730359a14518585931bc711f9ba15703c6
2 file for MongoDB Echo " Deb [arch=amd64,arm64] Http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 Multiverse " sudo Tee /etc/apt/sources.list.d/mongodb-org-3.4. List
3 . Reload Local Package databasesudo apt-get update
4 . Install the latest stable version of MongoDBsudoinstall -y mongodb-org
Step two : Start the service
Start MongoDB service, after default installation, is to start the MongoDB service
sudo Service Mongod Stop #停止服务 sudo service mongod start #启动服务
sudo service mongod restart #重新启动服务
sudo service mongod status #查看状态
Allow boot start, default when the server is restarted, MongoDB service will stop, need to set up start MongoDB service
sudo systemctl enable Mongod
Step three : Connect
This machine connects to the MongoDB service and uses the MONGO command to connect
Mongo
MongoDB configuration file
Less/etc/mongod.conf
Client connection, MONGO after the installation is complete, the default is only the native connection, outside the server is not able to connect MONGO
#切换至root用户 sudo -/etc/mongod.conf
After the modification is complete, save the file and restart MONGO
#退出root用户exit # Restart service sudo service mongod restart
Client Connection succeeded
Fourth Step : Delete MongoDB
sudo apt-get purge mongodb-org*
Ubuntu Install MongoDB