Cannot Connect server

image

when i type the ‘show collections’ command i did not get the collections. kindly help me

First, when you have a prompt like …:PRIMARY> then you are already connected to a server. You do not have to type mongo once again.

show collections shows the collections of the current database. It is possible that the current database does not have any collection. You may use show dbs to show the available databases and then use DatabaseName to make this database the current database.

2 Likes

Hi @Praveen_54345,

Please refer the post made by @steevej-1495.

If you still have any issue, feel free to get back to us. Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Hi, I selected “I have the Mongo Shell installed” option and copied the connection string, but it could not connect to server and the string is very different from the video. The following is the connection string.
mongo “mongodb+srv://cluster0-4di3j.mongodb.net/test” --username m001-student

Thanks,

Did it prompt for password for you?
I am able to connect

mongo “mongodb+srv://cluster0-4di3j.mongodb.net/test” --username m001-student
MongoDB shell version v4.0.5
Enter password:
connecting to: mongodb://cluster0-shard-00-00-4di3j.mongodb.net.:27017,cluster0-shard-00-01-4di3j.mongodb.net.:27017,cluster0-shard-00-02-4di3j.mongodb.net.:27017/test?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true
MongoDB server version: 4.0.12
Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.]
MongoDB Enterprise Cluster0-shard-0:PRIMARY> db
test
MongoDB Enterprise Cluster0-shard-0:PRIMARY> show dbs
admin 0.000GB
local 4.879GB

1 Like

Hi, In my case, there is no prompt for password and just shows some error message: Failed to parse mongodb…
image

Thanks!

It looks like that you did not copy the URI correctly because it starts with mongodb://mongodb+srv://. It should be mongodb+srv://.

1 Like

Problem solved. It is my bad. I have a old MongoDB version 3.4, so I didn’t set the PATH environment variable correctly. After I removed old one, it worked fine. Thanks!

1 Like