Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch / use <dbname> in MongoDB shell

I'm newbie with mongodb.

When I created the cluster it automatically created a database named < dbname > as far as I understood.

My problem now is, in the shell. How do I switch to this database and use it? If I try to switch to other existing dbs (use local / use admin) so it's okay. I tried to use < dbname > but I get an error saying < dbname > is not a valid database name.

Image provided - me trying to use < dbname > and getting an error

Thank you !

like image 407
Itay Avatar asked May 29 '26 14:05

Itay


1 Answers

You create Database From Compass GUI and use invalid characters: enter image description here

"The problem"

From mongodb docs:

https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Database-Names-for-Windows

Restrictions on Database Names for Windows

For MongoDB deployments running on Windows, database names cannot contain any of the following characters:

/\. "$*<>:|?

Example: enter image description here

Solution

Delete this database (By compass) - and create new database without < >.

Out of topic: Better practice to use more semantic DB names like Trips, Orders, and so on (And not db-name).

like image 111
Ezra Siton Avatar answered May 31 '26 05:05

Ezra Siton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!