I am trying to connect to a MongoLab DB using the credentials and user I set up. I chose the AWS instance using the 500mb of storage (the free Sandbox version). It said it was 3.0.x for Mongo (showing 3.0.9 in MongoLab).
On my environment I am running MongoDB shell version: 3.2.1
Using the command:
mongo ds011111.mongolab.com:11111/mydbname -u dbname -p dbpass
in the shell, I am able to connect to the DB just fine. However, when trying to connect through Robomongo, I am not. I am using the same username, password, database name, host and port. When I run the test, it connects to the host and port just fine, but it says Authorization Fails (this should not be, as I was just authorized to connect in the shell).
What is going?
There is nothing wrong. Just RoboMongo 0.8.x does not support Mongo 3.0+. You can download 0.9 RC4.
Related
I am new to mongodb.
I have db url, and I want to connect to that server from my ubuntu terminal and access data on terminal.
can anyone please help me how to connect?
Assuming you have the URI and the mongo shell installed, you can connect using the following command:
mongo <uri>
For example, if you want to log in as admin with the password mypassword through example.com on the port 27017, you can do:
mongo mongodb://admin:mypassword#example.com:27017/?authSource=admin
See:
how can I connect to a remote mongo server from Mac OS terminal
If mongodb version is 5.x.x
mongosh --host ip
I have deployed my meteor application on localhost for demo purpose by following what was mentioned here.
$export MONGO_URL='mongodb://localhost'
$ export PORT=3000
$ export ROOT_URL='http://example.com'
$ node main.js
I have had a bunch of collections in my meteor's mongo instance while development and need to move it to the new db that the deployed version connects to. I've taken a mongo dump of that and I know how to restore it. My question is, how exactly do I connect to the mongo db in order to do this?
I've tried:
mongo localhost
mongo localhost:3000
mongo -U localhost
They don't seem to work.
NOTE -
I do not want to run the mongo in development environment using meteor mongo. I have to deploy this in the client machine.
You can use the Meteor command line tools to attach to your local meteor instance.
meteor mongo
Taken from https://docs.meteor.com/commandline.html#meteormongo
Also, I think your commands didn't work 'cause the meteor mongo instance is hosted on port 3001 instead of 3000. Port 3000 hosts the actual meteor app, 3001 is the mongo instance.
As k.chao.0424 says you can use meteor mongo to connect to the mongo db via terminal or command line if you are using windows. But as i see you used the port 3000 for mongodb. I suggest you a simple way you just run the follwing command to run meteor and mongo db just write on your terminal:-
meteor
or if you are using ubuntu and any permission issues than write:-
sudo meteor
It will automatically run your project on 3000 port and your mongdb in 3001 port as by default after running app you can connect with mongodb via following command:-
meteor mongo
Hope this will help!
I have a Bitnami MEAN instance running on EC2. After much finagling, I've been able to successfully connect to the DB using the local shell. I created authenticated users with all of the permissions necessary to access the data, and when I run the below code -- I am able to access the DB with no problem.
sudo mongo admin -u <USERNAME-p <PASSWORD>
That said, when I try to repeat this using a remote connection I am repeatedly given an "auth failed" error from MongoDB.
mongo <HOST>:<PORT>/<DATABASE> -u <USERNAME> -p <PASSWORD>
...
This is strange because I am using the exact same credentials as I do in running the local shell. The only difference is I'm including the host and port information. I've since also confirmed that my remote connection DOES work if I disable the auth parameter in mongodb.config.
mongo <HOST>:<PORT>/<DATABASE>
Obviously, in production I want to be able to authenticate. Do any of you have suggestions as to why there is a discrepancy between remote and local authentication?
I was facing the same issue.
The problem for me:
My local mongo shell was v2.6.10. It uses an authentication method called MONGODB-CR that has been deprecated.
My server version is v3.0.4. It uses an authentication method called SCRAM-SHA-1.
Try to check your local shell and remote server versions with:
mongo --version
mongod --version
If they are different, upgrade your local shell to v3. (I had to uninstall and install it again.)
I had previously be installing MongoDB version 3.2.12 and was able to connect to a remote instance using:
mongo -u ‘<USERNAME>’ -p ‘<PASSWORD>’ --host <REPLICA_SET>/<HOST>:<PORT> admin
I am creating a new cluster with version 3.4.2 and was not able to connect with the same command. After trying many different options I was finally able to figure out that I needed to add --authenticationDatabase before the admin database.
mongo -u ‘<USERNAME>’ -p ‘<PASSWORD>’ --host <REPLICA_SET>/<HOST>:<PORT> --authenticationDatabase admin
If you're using more recent versions of MongoDB (server version 4.2.6 / shell version v3.6.9 in my case) you don't have to force them to match like in #Alexandre's example. For instance, if you're getting this error:
[thread1] Error: Authentication failed. :
DB.prototype._authOrThrow#src/mongo/shell/db.js:1608:20
You can connect with this syntax:
mongo --host mongodb://username:password#IP:PORT/ --authenticationDatabase admin
Install the same version both on the server and on the client solved the problem for me.
As #Alexandre explained above, it is probably a problem of password encryption.
MongoDB version 3.2.7
I tried successfully with the two methods:
mongo --host "your_host" --port "your_port" --username "your_user" --password "your_pass" --authenticationDatabase "your_admin_db"
mongo "your_host:your_port/your_db" --username "your_user" --password "your_pass" --authenticationDatabase "your_admin_db"
Besides, make sure that your server is available for remote accesses. See details about net.bindIp at https://docs.mongodb.com/v3.2/reference/configuration-options/
This is mainly due to security reasons.
When you have access to the local environment, it is easy to supposed that you are an administrator of the system or a developer because you have access to the machine itself.
If you don't have access to the local machine, you can't guarantee this, and since a database security is really important (in most cases), it makes sense not to enable remote access. You can, of course, disable this, but it is not recommended.
Hope I helped.
Just in case someone bumps into the same problem, the authenticationDatabase is only required if you created the user in ANOTHER database. If you create the user in the database you connect to, no problems.
So be careful : use then create user .
If you happen to create your user in the admin database then yes you need the authenticationDatabase flag.
Trying to make a remote connection from Robomongo to my ec2 ubuntu mongodb. I have been able to make connections to other non-ec2 ubuntu servers with Robomongo. But when I try with ec2 I keep getting the "you skipped authorization" error. I can remote connect to it in the terminal, but not with Robomongo. Is there something I a missing with ec2 remote connections?
What I have done:
created a mongo user administrator
make a connection within Robomongo
I am able to connect but says I skipped authorization.
My mongo log reads:
Failed to authenticate neil#admin with mechanism MONGODB-CR: AuthenticationFailed MONGODB-CR credentials missing in the user document
The Robomongo (at least 0.8.4) does not support Mongo 3.0 at this time.
For PHP, just update mongo.so module via pecl, because only 1.6 version is fully support Mongo 3.0.
https://github.com/paralect/robomongo/issues/766
How can I connect to the local Meteor's local mongoDB? Fyi, I want to use robomongo as the client. Where can I get the authentication details etc?
I'm using robomongo too
1) Just open robomongo,
2) Create new connection,
3)Give address localhost and port 3001
4) Click connect
Note: Meteor must be running to access the database
While you are creating new connection there is an authentication tab,there u can create username and password for db
enter command meteor mongo in the project directory while you are running the project. it will connect to a mongo shell of the project where you can see the mongo url.
example:
$ meteor mongo
MongoDB shell version: 2.4.9
connecting to: 127.0.0.1:3001/meteor