Skip to content

Commit 05f43c1

Browse files
committed
Add MongoDB
1 parent 7e86e97 commit 05f43c1

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

mongodb/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# MongoDB
2+
3+
4+
## Connect to your MongoDB server
5+
6+
We offer two ways to connect to your MongoDB server, using the web UI Admin Mongo or using the Mongo CLI.
7+
8+
9+
### Using Admin Mongo
10+
11+
To do that, just connect to your service in Stackhero's console, then go to the "admin panel".
12+
13+
You'll be connected then as user `admin`.
14+
15+
16+
### Using Mongo CLI
17+
18+
You can use this command to connect with the Mongo CLI: `mongo mongodb://<user>:<password>@XXXX.stackhero-network.com:27017/<database>?ssl=true`.
19+
20+
If you want to connect as `admin` to the database `admin`, you can use this command: `mongo mongodb://admin:<password>@XXXX.stackhero-network.com:27017/admin?ssl=true`.
21+
22+
23+
## Create databases / users
24+
25+
We strongly recommend to create a user per database.
26+
27+
To do that, you can use this command: `db.getSiblingDB("myDatabase").createUser({ user: "myUser", pwd: "myPassword", roles: [ { role: "readWrite", db: "myDatabase" } ], passwordDigestor: "server" })`.
28+
29+
In this case, you'll create a user named `myUser`, with password `myPassword` and roles read and write to the database named `myDatabase`.
30+
31+
Remember that you should be connected as `admin` to perform this.
32+
33+
34+
## Drop a user
35+
36+
You can drop a user `myUser` from a database `myDatabase` by using the command `db.getSiblingDB("myDatabase").dropUser("myUser")`.
37+
38+
39+
## Troubleshooting
40+
41+
42+
### Error `Use of SCRAM-SHA-256 requires undigested passwords`
43+
44+
You can get this error when trying to create a user with Admin Mongo UI.
45+
46+
To avoid this error, use the Mongo query you'll find in [Create databases / users](#create-databases-/-users).
47+

0 commit comments

Comments
 (0)