我需要一點(diǎn)幫助。我無(wú)法從 MongoDB 數(shù)據(jù)庫(kù)中刪除“System.User”用戶。/*Remove Tenent DB*/function RemoveTenentDB($mydb){ error_reporting(0); $connection_string = Config::get('database.creator-tenant-uri'); $m = new MongoClient($connection_string); //create interface to mongo $command = array ( "dropUser" => $mydb ); $db = $m->selectDB( $mydb ); $db->command( $command ); #drop databse $db = $m->dropDB( $mydb ); return true;}下面的代碼只刪除數(shù)據(jù)庫(kù)和特定的數(shù)據(jù)庫(kù)用戶,而不是“System.User”$command = array ( "dropUser" => $mydb ); $db = $m->selectDB( $mydb ); $db->command( $command ); $db = $m->dropDB( $mydb );
2 回答

繁華開滿天機(jī)
TA貢獻(xiàn)1816條經(jīng)驗(yàn) 獲得超4個(gè)贊
以下 db.dropUser() 操作將 reportUser1 用戶刪除到產(chǎn)品數(shù)據(jù)庫(kù)中。
use products db.dropUser("reportUser1", {w: "majority", wtimeout: 5000})
參考:db.dropUser
嘗試以下代碼的php
$users = $conn->$db_name->selectCollection('system.users')->delete();

侃侃爾雅
TA貢獻(xiàn)1801條經(jīng)驗(yàn) 獲得超16個(gè)贊
如果我理解正確,您正在尋找使用 PHP 刪除 mongodb 數(shù)據(jù)庫(kù)中的一個(gè)集合。如果是這種情況,您可以使用以下方法從 mongodb 中刪除一個(gè)集合。
$collection = $mongo->my_db->System.User;
$response = $collection->drop();
您可以按照以下鏈接獲取有關(guān)相同內(nèi)容的更多詳細(xì)信息 - https://www.php.net/manual/en/mongocollection.drop.php
- 2 回答
- 0 關(guān)注
- 120 瀏覽
添加回答
舉報(bào)
0/150
提交
取消