我需要一点帮助。
我无法从数据库中删除System.User“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;
}下面的代码只删除数据库和特定的数据库用户,而不是"System.User"
$command = array
(
"dropUser" => $mydb
);
$db = $m->selectDB( $mydb );
$db->command( $command );
$db = $m->dropDB( $mydb );

发布于 2020-01-01 14:31:16
下面的db.dropUser()操作将reportUser1用户放到产品数据库中。
use products
db.dropUser("reportUser1", {w: "majority", wtimeout: 5000})参考资料:db.dropUser
尝试使用下面的php代码
$users = $conn->$db_name->selectCollection('system.users')->delete();发布于 2020-01-01 14:26:30
如果我正确理解它,您将使用PHP删除mongodb数据库中的一个集合。如果是这样的话,您可以使用下面的方法从mongodb中删除一个集合。
$collection = $mongo->my_db->System.User;
$response = $collection->drop();
您可以按照下面的链接获得有关同一- https://www.php.net/manual/en/mongocollection.drop.php的更多细节。
https://stackoverflow.com/questions/59551691
复制相似问题