MongoDb: Difference between revisions

From Objectif Client Inc
Jump to navigation Jump to search
Line 14: Line 14:
* Remove Database (Collections)
* Remove Database (Collections)
<pre>db.dropDatabase()</pre>
<pre>db.dropDatabase()</pre>
=== User Management ===
* Create Admin user
* Create Admin user
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
Line 25: Line 26:
)
)
</syntaxhighlight>
</syntaxhighlight>
=== Database Engine Management ===
* Stop Database
* Stop Database
<syntaxhighlight lang="JavaScript">
<syntaxhighlight lang="JavaScript">
db.adminComand( { shutdown: 1} )
db.adminCommand( { shutdown: 1} )
</syntaxhighlight>
</syntaxhighlight>



Revision as of 18:42, 6 June 2020

Cheat sheet

  • Connect to a mongodb
mongo
  • Display dabases
show dbs
  • Connect to a database
use database
  • List Tables (Collections)
show collections
  • Display content of a table
db.collection.find()
  • Remove Tables (Collections)
db.collection.drop()
  • Remove Database (Collections)
db.dropDatabase()

User Management

  • Create Admin user
use admin
db.createUser(
   {
     user: "userName",
     pwd:  "passWord",
     roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
   }
)

Database Engine Management

  • Stop Database
db.adminCommand( { shutdown: 1} )

Http Interface

Inable Http Interface

add http.enabled: true in /etc/mongod.conf

net:
  port: 27017
  bindIp: 127.0.0.1
  http.enabled: true
  http.RESTInterfaceEnabled: true

Access to htps interface

Http Interface