Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
development:database:mongodb [2021/07/05 20:54]
kalenpw
development:database:mongodb [2021/07/06 10:13] (current)
kalenpw
Line 5: Line 5:
 ===== Basics ===== ===== Basics =====
 Runs on port:  ''27017'' Runs on port:  ''27017''
 +
 +----
 +===== Show databases =====
 +<code mongodb>
 +show dbs
 +</code>
  
 ---- ----
Line 10: Line 16:
 <code mongodb> <code mongodb>
 use db_name # if db_name doesn't exist it will create it use db_name # if db_name doesn't exist it will create it
 +# However, db_name will not be saved unless you create a collection
 +db.createCollection("Collection0")
 </code> </code>
  
Line 16: Line 24:
 <code mongodb> <code mongodb>
 # first user # first user
 +use admin
 > db.createUser( > db.createUser(
 ... { ... {
Line 24: Line 33:
 ... ) ... )
  
-ensure you: use db_name +user for specific database 
 +use db_name
 > db.createUser( > db.createUser(
 ... { ... {