Failed to connect to mLab by mongo - node.js

I tried to connect to mLab on my terminal when I followed the instruction on the website
This is the command that I typed
mongo ds151461.mlab.com:51461/simplelogin -u <dbuser> -p <dbpassword>
This is the result I got:
MongoDB shell version v3.4.4
connecting to: mongodb://ds151461.mlab.com:51461/simplelogin
MongoDB server version: 3.2.13
WARNING: shell and server versions do not match
2017-06-12T19:12:35.498-0400 E QUERY [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow#src/mongo/shell/db.js:1459:20
#(auth):6:1
#(auth):1:2
exception: login failed
Btw, when I run the local mongoDB, I use mongod to make it work and mongo does not work

As the error suggests you have an authentication error.
Which is possibly happening because you are using credentials of a user that is not valid for the database "simplelogin".
(You can't use mlab credentials here, I made this mistake, might help someone, so worth a mention.)
If you don't have a user in the database yet. Follow following steps to create a user.
1 - Go to your database page, by clicking on the database from the landing page.
Or use following url, https://mlab.com/databases/simplelogin (you have to be logged in for this to work)
2 - From there click the "Users" tab. Click on the button that says "Add database user", and enter username and password (lets say username - "myuser" and password - "mypassword" for this illustration). Click the "Create" button.
3 - Use those credentials to connect to your database.
mongo ds151461.mlab.com:51461/simplelogin -u myuser -p mypassword
And it should work.
Does this help?

Related

postgreSQL password authentication failed for user

I'm taking a full WebDev course and got really hard stuck on this matter. I've installed postgreSQL 14.2 for Windows 10 and the instructor said that pgAdmin4 would come together, which it didn't, so then i installed pgAdmin4 individually. I've setted everything up and created a testing database, which is called 'test', and also a table, everything through Windows Powershell command lines, following the course instructions. Now, when i try to access this database through PowerShell command psql 'test' and type the requested password for the OS user i get a Fatal Error, which follows:
PS C:\Users\theu_\desktop> psql 'test'
Password for user theu_:
psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL: password authentication failed for user "theu_"
I've tried my OS username password and the postgreSQL password, none of them works. What am i missing or did wrong?
Thanks in advance
Try accessing postgres by using psql -U postgres in cmd, postgres being the name of the superuser for postgres itself (if you did a basic install) - while windows is probably trying to access postgres with your windows name.
You should also be able to use SQL Shell to access your database without denoting a user.

Why can I login to my database using my .pgpass credentials, but not use pg_dump?

After updating my computer I am unable to do automatic backups of my PostgreSQL 12 database, which has the version:
psql (PostgreSQL) 12.8 (Ubuntu 12.8-Ubuntu0.20.04.1)
Before updating, I was able to run the following code, both manually and using crontab:
pg_dump -h localhost -p 5432 -U brian -d example_db > '/home/brian/.../example_db.bak'
The error I now get is:
pg_dump: error: connection to database "example_db" failed: FATAL: password authentication failed for user "brian"
password retrieved from file "/home/brian/.pgpass"
FATAL: password authentication failed for user "brian"
password retrieved from file "/home/brian/.pgpass"
I have confirmed that my ".pgpass"-file lives up to the manual described here:
PostgreSQL 12 Manual: pgpass
I am also able to log in to my database without being prompted for a password:
brian#pc:~$ psql -U brian -d example_db
Would anyone have an idea why I am unable to use pg_dump when I am able to login to my database without being prompted for my password?

MongoDB atlas through mongo shell: "Error: bad auth : Authentication failed." what could possibly cause this Authentication failure?

I have a problem connecting to MongoDB atlas through mongo shell, even though I have done everything right and triple checked data username and password, included my IP in the whitelist, changed the database name to test, and tried adding --password in the same line
`$ mongo "mongodb+srv://cluster******.mongodb.net/test" --username admin --password admin
MongoDB shell version v4.4.6
connecting to: mongodb://cluster0-shard-00-00.4d5jd.mongodb.net:27017,cluster0-shard-00-01.4d5jd.mongodb.net:27017,cluster0-shard-00-02.4d5jd.mongodb.net:27017/test?compressors=disabled&gssapiServiceName=mongodb&ssl=true
*** You have failed to connect to a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.
Error: bad auth : Authentication failed. :
connect#src/mongo/shell/mongo.js:374:17
#(connect):2:6
exception: connect failed
exiting with code 1`
MongoDB Atlas creates all users in the admin database.
The output from your attempt does not indicate that it was using the admin database for authentication, so you will likely need to use either the --authenticationDatabase command line option, or include authSource= in the URL, i.e. one of:
mongo "mongodb+srv://cluster******.mongodb.net/test" --username admin --password admin --authenticationDatabase admin
or
mongo "mongodb+srv://cluster******.mongodb.net/test?authSource=admin" --username admin --password admin

invalid username and password snowsql

While login to snowflake from command prompt I'm getting the below error
the error:
250001 (08001): Failed to connect to DB:
EGA12345.us-east-1.snowflakecomputing.com:443. Incorrect username or
password was specified. If the error message is unclear, enable
logging using -o log_level=DEBUG and see the log to find out the
cause. Contact support for further help.
I can able to log into web UI by using the same username and password, but not from snowsql
command is snowsql -a EGA12345.us-east-1 -u venu
thanks in advance.
Venu
Check what role you're using via snowsql. The default role would be "defaultrolename", which I doubt exists for your account. I tested this by changing the .snowsql/config file to have a connection where rolename=non-existing-role. Using that connection, I get the error in your original post.

MongoDB auth=true clusterAdmin still has lack of priveleges

I need a little help with mongo.
I installed 2.4.9 version from accroding to this instructions:
For ubuntu - http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
For Debian - http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/
I followed manuals and documentation. Everything worked fine but when I change mongo settings to "auth=true" permissions go crazy.
Here is my user:
{
"_id" : ObjectId("5305dd8729ae7b95a4bde944"),
"user" : "root",
"pwd" : "063bbfd478f7b78df6c93b6202af9145",
"roles" : ["clusterAdmin", "userAdminAnyDatabase",
"readWriteAnyDatabase", "dbAdminAnyDatabase" ] }
I used rockmongo. And when I open my mongodb it says that I don't have enough permissions to run command db.getCollectionNames()
It says: Execute failed:unauthorized
And the same thing for creating users, managing databases.
I can't imagine what more permissions should I provide to user.
As it is said in manual this user is the first one I created. I gave him all highest admin privileges.
After changing auth parameter to auth=true
I also can't login in command line.
$ mongo -uroot -p <my password> --host 127.0.0.1
MongoDB shell version: 2.4.9
connecting to: 127.0.0.1:27017/test
Thu Feb 20 11:56:17.510 Error: 18 { code: 18, ok: 0.0, errmsg: "auth fails" } at src/mongo/shell/db.js:228
exception: login failed
By the way I tried password with and without braces. With long option and short one. This way -p<my password> and this way -p <my password>
But application (use simple db users) works fine.
I created database and two users (before making auth=true) and they seems fine for applications that use them.
I couldn't google any information. In most cases adding clusterAdmin or other permissions solves the problem for them.
OS: Ubuntu 12.04 and Debian 7 (In both same behavior)
MongoDb: 2.4.9
What is my mistake?
Did you create the user on the admin database?
clusterAdmin and the *AnyDatabase permissions apply only on the admin database.
When you authenticate, you'll need to authenticate against the admin database and then access other databases according to user's permissions.
mongo --authenticationDatabase admin -u root -p <my password> --host 127.0.0.1

Resources