MongoDb: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 14: | Line 14: | ||
* Remove Database (Collections) | * Remove Database (Collections) | ||
<pre>db.dropDatabase()</pre> | <pre>db.dropDatabase()</pre> | ||
* Create Admin user | |||
<syntaxhighlight lang="JavaScript"> | |||
mongo | |||
db.createUser( | |||
{ | |||
user: "userName", | |||
pwd: "passWord", | |||
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ] | |||
} | |||
) | |||
</syntaxhighlight> | |||
== Http Interface == | == Http Interface == |
Revision as of 18:33, 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()
- Create Admin user
mongo
db.createUser(
{
user: "userName",
pwd: "passWord",
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)
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