Mongorestore "auth fails" at deployed app at meteor.com - mongodb

I received the information from my deployed app by using the command
meteor mongo -url bhedir.meteor.com
I then took the response and used the info for my
mongorestore -u client -p meteorinfo - h meteorinfo -d bhedir_meteor_com meteordump/meteor
however, I keep getting the following error:
assertion: 18 { code: 18, ok: 0.0, errmsg: "auth fails" }
I should note that I have several meteorite packages included but I don't see how that would affect this.
Also, I've done this before, granted not that many times, but did not run into any issues. Any advice would be greatly appreciated.

I assume 'meteorinfo' is a placeholder for the hostname and password you get out?
If so then when you get the auth info with meteor mongo -url bhedir.meteor.com you have to be very quick to do the mongorestore as the auth data you get only lasts 1 minute, then it expires and you have to do the meteor mongo --url bhedir.meteor.com call again

You forgot some required parameter as might be the username, password or db

Related

I'm trying to connect to mongodb Atlas but I keep getting error and can't proceed

My error goes :
mongo "mongodb+srv://cluster0-ts5b5.mongodb.net/test" --username admin-David
MongoDB shell version v4.0.6
Enter password: Cannot get console mode 6
I meant to write password there but I can't proceed to password so I can't connect to Atlas at all. Please sort this problem!!
I ran into this same problem today, I was able to log in by including the password in the same statement where the url and username are.
So in your case try doing this:
mongo "mongodb+srv://cluster0-ts5b5.mongodb.net/test" --username admin-David --password <yourPasswordHere>
That worked for me, hopefully it helps!
MongoDB docs reference: https://docs.mongodb.com/manual/reference/program/mongo/#cmdoption-mongo-username

Can't Connect to Mlab

I have a very simple Mlab account and I'm trying to connect via command line with this command:
mongo server_name.mlab.com:port/inventory -u <dbuser> -p <dbpassword>
but I keep running into this problem:
2016-05-26T15:41:18.195+0200 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1210
exception: login failed
How do I get rid of this and how can I connect to mlab easily?
I think that you're using your mLab credentials. You must set a DB User at the User Tab like this:
If (like me) you were positive that you were using the correct credentials for the database and for some reason you were still getting the Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } thing, here's what I did.
First check your version of mongo.
$ mongo --version
If it is less than 3.x.x congratulations, you've found the problem.
For my linux users out there, go here to update your mongo. After that your connection should succeed!
I had the same problem, if your username and password is correct then the issue connecting is your firewall blocking certain ports.
Use a different internet connection and it will work.
Make sure to create a user with a different username and password than your mLab account.
In addition to Rafa's answer, if you choose to create a user with the same username and password as your mLab account (which is what I did to save myself from remembering another username and password), you will also not be able to connect.
Upon deleting that user and creating a new one, I was immediately able to connect.

How to check meteor production database [duplicate]

It seems the answer in this thread (Accessing Meteor production database) does not work anymore when you want to access a meteor production database in 2016. I want to access a meteor production database blah.meteor.com using
meteor mongo blah.meteor.com
instead what I get is:
connecting to: sg-mother1-6243.servers.mongodirector.com:27017/blah_meteor_com
2016-01-18T15:21:49.884+0200 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:1210
exception: login failed
Then I tried
meteor mongo --url blah.meteor.com
I get username cursor. I enter my meteor site username and press enter and then get password cursor. I enter password for the above username and press enter. I get presented with the following url:
mongodb://client-2ee8c14d:c1546ca8-4e7e-5883-0214-150b309fb4fb#SG-mother1-6242.servers.mongodirector.com:27017/blah_meteor_com
Then every time I re-enter
meteor mongo --url blah.meteor.com
I am assumed to have logged on already, and I just get presented with a similar url to the one I was presented with just above.
I read the "meteor mongo command" documentation by entering:
meteor mongo --help
In the documentation I read the following line:
Instead of opening a shell, specifying --url (-U) will return a URL
suitable for an external program to connect to the database. For remote
databases on deployed applications, the URL is valid for one minute.
For the meaning, I went back to the thread (stackoverflow.com/questions/11801278/accessing-meteor-production-database) I mentioned in the beggining and read:
"So what it's saying is, the url provided by running the command with the --url option is for connecting to the database by some external application, i.e. other than meteor."
I don't know what other application can help me connect to meteor production database other than what I used to do in 2015, which is:
meteor mongo blah.meteor.com
I read somewhere that I can use the mongo shell intead but I don't know how to open it and I don't know the mongo installation directory when it is installed with meteor. I am using linux (fedora) OS.
How do I access meteor production database in 2016? Are there upgrades that happened that make me not to be able to access meteor production database as easily as I did in 2015?
You are trying to connect to a database version 3.0 while your meteor mongo command still use the version 2.6.7 of mongo
Try this workaround :
Install Mongo version (3.x) directly on your machine.
Then run this command (should work on osx, linux and windows when sed is installed):
mongo `meteor mongo --url XXX.meteor.com | sed 's/mongodb:\/\//-u /' | sed 's/:/ -p /' | sed 's/#/ /'`
Source: https://forums.meteor.com/t/meteor-mongo-xxx-meteor-com-giving-exception-login-failed-workaround/15289
Since Meteor stopped supporting the use of .meteor domains and every developer needs to get his hosting by himself, I found a way accessing the remote's database by using mup or mupx. I wrote it in this post: https://stackoverflow.com/a/37439315/2908071
I hope this will help future people.

Can't insert anything in MongoHQ database

I registered for a free sandbox database on MongoHQ.
As I am starting to use mongoDB I thought it would be a good idea to connect to MongoHQ database from the mongo console and run some commands before using it in any program.
I tried connecting to my database using:
Here testuser is my username and 123456 is my password (I know posting user id and passowrd on forums is bad, this user is temporary and will be deleted by me later).
mongo oceanic.mongohq.com:10076/tnh_data -u testUser -p 123456
and I got this:
MongoDB shell version: 2.4.9
connecting to: oceanic.mongohq.com:10076/tnh_data
Hoping that everything is running fine I tried running a few commands, but I am getting a not authorized error.
> show dbs
Sat Apr 19 22:00:18.090 listDatabases failed:{ "ok" : 0, "errmsg" : "unauthorized" } at src/mongo/shell/mongo.js:46
> use learn
switched to db learn
> db.collection0.insert({name: 'Harry', gender: 'Male'})
not authorized for insert on learn.collection0
Please help me what am I doing wrong ?
Just for the information. I created the users using the web interface on mongoHQ.
When using MongoHQ sandbox plans and logging in from the console, there are a couple of things that are at play:
When you connected, using the string above, you are already in your database (tnh_data)
You do not have admin-level access, so "show dbs" will not work in MongoDB console.
So, in MongoDB console, connect again using the same string you started with and, once connected, run this command: "show collections".
Also, without trying to switch to another database, run your insert again. It should work normally this time.
Hope this information is helpful!

Unable to connect to MongoLab "auth fails" error

I am new to mongo. Recently created an account in mongoLab.
I am trying to connect to the database using the below statement.
mongo ds039487.mongolab.com:39487/webbies -u <dbuser> -p <dbpassword>
Getting the below error
MongoDB shell version: 2.4.8
connecting to: ds039487.mongolab.com:39487/webbies
Wed Dec 11 22:30:16.686 Error: 18 { code: 18, ok: 0.0, errmsg: "auth fails" } at src/mongo/shell/db.js:228
exception: login failed
Note:
dbuser - is an User created in mongoLab
What is missing in this? Kindly advice.
Old thread, but just in case it helps anyone else: my problem was using shell version 2.4.9 to connect to mongo db version 3.0.7 (http://docs.mongolab.com/connecting/#mongo_shell).
Updating my shell sorted it (https://docs.mongodb.org/master/tutorial/install-mongodb-on-ubuntu/).
Thanks to pneumee.
The issue was because I was using my mongolab.com username and password, instead of the database username and password.
It is working now.
OK - I figured it out and would also like to add onto pneumee's answer.
Go to mongolab.com
Login.
Navigate to the "Users" tab.
If you have forgotten your Username and Password for the database, I suggest you "Add a new user" and supply it with the username and password.
default users in db
login: admin
password: admin
check users in
https://mongolab.com/databases/MYDBNAME#users
my problem was being putting login and password mongolab