From 2f8e5af236fb25fc281844d4d3b4ad9412a3afbc Mon Sep 17 00:00:00 2001 From: lniwn Date: Fri, 13 Mar 2020 19:24:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=96=87=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/posts/2019/curl手册.md | 7 +++++ content/posts/2019/mongodb备忘录.md | 38 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 content/posts/2019/curl手册.md diff --git a/content/posts/2019/curl手册.md b/content/posts/2019/curl手册.md new file mode 100644 index 0000000..721794e --- /dev/null +++ b/content/posts/2019/curl手册.md @@ -0,0 +1,7 @@ +--- +title: "Curl手册" +date: 2019-09-09T21:39:16+08:00 +draft: true +--- + +http://www.ruanyifeng.com/blog/2019/09/curl-reference.html \ No newline at end of file diff --git a/content/posts/2019/mongodb备忘录.md b/content/posts/2019/mongodb备忘录.md index 2801847..8145f90 100644 --- a/content/posts/2019/mongodb备忘录.md +++ b/content/posts/2019/mongodb备忘录.md @@ -51,4 +51,42 @@ categories: server db.games2.find({$where: "this.fileId == this.fileUid"}); ``` + +- 创建管理员用户 + + ```javascript + use admin + db.createUser({ + user: "username", + pwd: "password", + roles: ["root"] + }) + + db.createUser({ + user: "myUserAdmin", + pwd: passwordPrompt(), // or cleartext password + roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ] + } + ) + ``` + +- 创建数据库用户 + + ```javascript + use mydb + db.createUser({ + user: "myTester", + pwd: passwordPrompt(), // or cleartext password + roles: [ { role: "readWrite", db: "mydb" }, + { role: "read", db: "reporting" } ] + } + ) + ``` + +- 连接数据库 + + ```javascript + mongo --port 27017 -u "myTester" --authenticationDatabase "mydb" -p + ``` + \ No newline at end of file