1. 程式人生 > >MongoDB ver 4 幾個常用命令

MongoDB ver 4 幾個常用命令

create eat user pic dbo 常用 role 常用命令 pwd

1. 為某個數據庫創建用戶:

use db_test1;

db.createUser({
user:"test_user_1",
pwd:"test_user_1_pwd",
roles:[{role:"dbOwner",db:"test_db_1"}]});

2. 在某個數據庫中刪除用戶:
db.dropUser("notaboouser");

3. 創建一個集合,查看集合:

db.createCollection("topic")

show collections

MongoDB ver 4 幾個常用命令