How do you know that?
When using non-mongoose application like the mongo shell and using your URI with /test1 after the port number, I see that I am using the test1 database:
With /test1 after the port number and before the question mark
: steevej @ mint-1 ; mongo 'mongodb://UserName:Password@HostName:27017/test1?authMechanism=SCRAM-SHA-1&authSource=test1'
MongoDB shell version v4.0.25
connecting to: mongodb://HostName:27017/test1?authMechanism=SCRAM-SHA-1&authSource=test1&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("22315b5e-ebad-44b0-8714-133b08488c63") }
MongoDB server version: 5.0.3
WARNING: shell and server versions do not match
> db
test1
> exit
bye
and now without /test1 after the port number and before the question mark.
: steevej @ mint-1 ; mongo 'mongodb://UserName:Password@HostName:27017/?authMechanism=SCRAM-SHA-1&authSource=test1'
MongoDB shell version v4.0.25
connecting to: mongodb://HostName:27017/test?authMechanism=SCRAM-SHA-1&authSource=test1&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("22315b5e-ebad-44b0-8714-133b08488c63") }
MongoDB server version: 5.0.3
WARNING: shell and server versions do not match
> db
test
> exit
bye
So it may not be moogoose, but it is certainly not the underlining mongo driver. And with such a big difference of behavior between Windows and Ubuntu, it must be something else that you do in your setup.
By the way change the password of the user Tyme. Although you edited your previous post the real URI with the real password of this user is still readable.
This is while connected to your server:
> use test1
switched to db test1
> show collections
> use test
switched to db test
> show collections
Warning: unable to run listCollections, attempting to approximate collection names by parsing connectionStatus
> use test1
switched to db test1
> db.getUsers()
[
{
"_id" : "test1.Tyme",
"userId" : UUID("86ea443d-e7a0-4a51-b2a1-265da2caa972"),
"user" : "Tyme",
"db" : "test1",
"roles" : [
{
"role" : "dbOwner",
"db" : "test1"
}
],
"mechanisms" : [
"SCRAM-SHA-1",
"SCRAM-SHA-256"
]
}
]
> exit
bye