I need a small help.
I can not delete "System.User" user from MongoDB database.
/*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;
}
Below code delete just database and particular database user only not "System.User"
$command = array
(
"dropUser" => $mydb
);
$db = $m->selectDB( $mydb );
$db->command( $command );
$db = $m->dropDB( $mydb );
The following db.dropUser() operation drops the reportUser1 user on the products database.
use products
db.dropUser("reportUser1", {w: "majority", wtimeout: 5000})
reference : db.dropUser
Try following code for php
$users = $conn->$db_name->selectCollection('system.users')->delete();
I need a small help.
I can not delete "System.User" user from MongoDB database.
/*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;
}
Below code delete just database and particular database user only not "System.User"
$command = array
(
"dropUser" => $mydb
);
$db = $m->selectDB( $mydb );
$db->command( $command );
$db = $m->dropDB( $mydb );
If I understand it right, you are looking for deleting one collection in mongodb database using PHP. If that is the case then, you can use the below method to drop a collection from mongodb.
$collection = $mongo->my_db->System.User;
$response = $collection->drop();
You can follow the below link to get more details about the same - https://www.php.net/manual/en/mongocollection.drop.php
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.