mongodb installation under Centos7 and its simple and practical application

i skeleton spirit Concern August 20, 2018 17:45 * words 141 read 76 comments 0 like 0 mongodb version: 4.0 Official website installation tutorial For...

i skeleton spirit Concern

August 20, 2018 17:45 * words 141 read 76 comments 0 like 0

mongodb version: 4.0

Official website installation tutorial

For the installation and uninstallation tutorial, see Official website

Frequently used commands

  • Start / close database
sudo service mongod start sudo service mongod stop

Restart database

sudo service mongod restart

View database service status

systemctl status mongod.service
  • Basic operation of database

  • Database operations
#If the database does not exist, create the database, otherwise switch to the specified database. vue creates the database name for you use vue #View current database db #Delete the database. The deleted database is the current database. You can use the db command to view it db.dropDatabase() #View all databases show dbs
#The newly created database is not in the list of databases. To display it, we need to insert some data into the database db.createCollection("User") Create a set merge insert a document db.User.insert({"name":"vue learning"})

Delete set Delete set

//View all collections show collections //Collection name is the name of the collection to be deleted db.COLLECTION_NAME.drop()
db.COLLECTION_NAME.insert(document)
  • User and rights management

  • Enable permission verification
    Add in profile

security: authorization: enabled
  • Common mistakes
2018-08-20T17:18:53.815+0800 I CONTROL [main] ***** SERVER RESTARTED ***** 2018-08-20T17:18:54.263+0800 I CONTROL [initandlisten] MongoDB starting : pid=2131 port=27017 dbpath=/var/lib/mongo 64-bit host=solumon 2018-08-20T17:18:54.263+0800 I CONTROL [initandlisten] db version v4.0.1 2018-08-20T17:18:54.263+0800 I CONTROL [initandlisten] git version: 54f1582fc6eb01de4d4c42f26fc133e623f065fb 2018-08-20T17:18:54.263+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013 2018-08-20T17:18:54.263+0800 I CONTROL [initandlisten] allocator: tcmalloc 2018-08-20T17:18:54.263+0800 I CONTROL [initandlisten] modules: none 2018-08-20T17:18:54.263+0800 I CONTROL [initandlisten] build environment: 2018-08-20T17:18:54.263+0800 I CONTROL [initandlisten] distmod: rhel70 2018-08-20T17:18:54.263+0800 I CONTROL [initandlisten] distarch: x86_64 2018-08-20T17:18:54.263+0800 I CONTROL [initandlisten] target_arch: x86_64 2018-08-20T17:18:54.263+0800 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1", port: 27017 }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid", timeZoneInfo: "/usr/share/zoneinfo" }, storage: { dbPath: "/var/lib/mongo", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } } 2018-08-20T17:18:54.264+0800 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock Unknown error 2018-08-20T17:18:54.264+0800 F - [initandlisten] Fatal Assertion 40486 at src/mongo/transport/transport_layer_asio.cpp 707 2018-08-20T17:18:54.264+0800 F - [initandlisten]

This kind of error is reported in the log file

Processing: delete the mongodb-27017.sock file under the / tmp / folder

Let's go for a little gift. Let's brief the book and pay attention to me

2 December 2019, 12:50 | Views: 1920

Add new comment

For adding a comment, please log in
or create account

0 comments