mongod 對指定資料庫建立使用者

2022-08-08 23:30:18 字數 776 閱讀 9239

1、先在admin庫中建立管理員使用者與密碼

[root@mbasic ~]# mongo

mongodb shell version: 3.2.6

connecting to: test

> use admin //切換到admin資料庫

switched to db admin

> db.createuser( //建立使用者

... ] //指定資料庫許可權

... }

... )

successfully added user:

]}>

2、先用管理員帳號密碼登入admin庫,然後切換到要設定的庫(test)然後在使用db.createuser命令建立使用者即可

[root@mbasic ~]# mongo

mongodb shell version: 3.2.6

connecting to: test

> use admin

switched to db admin

> db.auth('myuseradmin','abc123')

1> use test

switched to db test

> db.createuser(

... ] //對test庫賦予readwrite許可權

... }

... )

successfully added user:

]}>

Mysql之建立指定資料庫操作許可權的資料庫使用者

以下示例為建立乙個具有一定許可權的資料庫 資料庫賬號僅對當前資料庫生效 建立乙個新的空資料庫。預設編碼為utf8 create database dbname default character set utf8mb4 collate utf8mb4 unicode ci 為資料庫建立具有適當許可權...

強制關閉指定資料庫連線

強制關閉指定資料庫連線 還原資料庫的時候是不是經常出現資料庫正在使用無法還原?雖然關掉所有程式,可是還是還原不了資料庫?執行以下 吧!斷開所有使用者開啟的連線 use master go if exists select from dbo.sysobjects where id object id ...

指定資料庫讀寫分離操作

方式一 是檢視裡面用using方式可以進行指定到哪個資料讀寫 普通使用者 手動指定去某個資料庫取資料 方式二 寫配置檔案 class router1 指定到某個資料庫取資料 def db for read self,model,hints attempts to read auth models g...