How can I write a query to connect mongodb? - mongodb

I have installed mongodb in different server. I have modified my old code
db: 'mongodb://localhost/dev',
to new code
my username : proUseAdd
password : mongodb#23
ip : 169.213.64.127
I modified like this
db: 'mongodb://proUseAdd:mongodb#23#169.213.64.127:27017/dav',
I am getting this error
Could not connect to MongoDB!
Error: failed to connect to
[23#169.213.64.127:27017]
UPDATE
i have tried changed my password:mongodb23
query strin:
db: 'mongodb://proUseAdd:mongodb23#169.213.64.127:27017/dav',
still i'm getting error
Could not connect to MongoDB!
Error: failed to connect to
[169.213.64.127:27017]

Change your password to something which doesn't contain #.
While parsing your connection string, MongoDB driver looks for the # character to separate your credentials and the host name. Since your password has an # in it, it recognizes your credentials as proUseAdd:mongodb and your host name as 23#169.213.64.127:27017.

Related

IntelliJ Database explorer won't work with localhost Mongo 4.4.3

I'm up-the-middle MongoDB with authentication localhost. I have the mongod configured to bind a specific user to a specific database and from the mongo shell and my Java programs, everything works great. When I log in as that user I can do all the mongo stuff on the mongo db I bound that user to.
$ mongo -u totallyLegitUser --authenticationDatabase admin
MongoDB shell version v4.4.3
Enter password:
connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("2ba7a3f6-2ca1-49b7-8241-8133ceb3d842") }
MongoDB server version: 4.4.3
> use mfg-plan;
switched to db mfg-plan
> show collections;
activity
...
When I try to set up the same user through IntelliJ's "Database" thing, the "Test Connection" says everything is fine, but I can't run any queries through the console and the "explorer" drop down thing doesn't show collections I know are in the database.
This is what shows up when I look in the console after I've try to run the db.activity.findOne(); from the cli session...
com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-256, userName='totallyLegitUser', source='mfg-plan', password=<hidden>, mechanismProperties=<hidden>} com.mongodb.MongoCommandException: Command failed with error 17 (ProtocolError): 'Attempt to switch database target during SASL authentication.' on server localhost:27017. The full response is {"ok": 0.0, "errmsg": "Attempt to switch database target during SASL authentication.", "code": 17, "codeName": "ProtocolError"}
I have confirmed that the username, password, and database are all correct.
How do I get IntelliJ to connect to my authenticating mongos?
Problem solved. In the "Data Sources and Drivers" dialog for my mongo hosts it asks for a Database. I was giving it the database I wanted to connect to on the host (mfg-plan). What it wants is the authenticationDatabase for the host (usually 'admin'). When I change that to 'admin', all is well.

Cannot connect to my PostgreSQL server remotely from chainlink node terminal

I have tried everyting to connect my Chainlink node up to my postgresql database with no luck. I have scoured the interwebs for answers to no avail...
Here is the error message I am receiving:
[ERROR] failed to initialize database, got error failed to connect to `host=/tmp user=root database=`: dial error (dial unix /tmp/.s.PGSQL.5432: connect: no such file or directory)
Here is my .env file:
ROOT=/chainlink
LOG_LEVEL=debug
ETH_CHAIN_ID=42
MIN_OUTGOING_CONFIRMATIONS=2
LINK_CONTRACT_ADDRESS=0xa36085F69e2889c224210F603D836748e7dC0088
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false
GAS_UPDATER_ENABLED=true
ALLOW_ORIGINS=*
ETH_URL=wss://kovan.infura.io/ws/v3/id...
DATABASE_URL=https://chainlink-db-url://postgres:Password#chainlink-kovan:5432
I have tried every configuration of the connection string. Also I am able to connect to the db via pgAdmin no problem and the dbs are publicaly accessible.
The postgresql database is on AWS.
Please change the syntax of your DATABASE_URL to:
DATABASE_URL=postgresql://"username":"password"#"public-ip-pg-server":5432/"database-name"
just change:
"username" : you need to configure a new user, because the default/admin user postgres will not work for it.
"password" : password of the user
"public-ip-pg-server" : the public ip address of your postgresql-server
"database-name" : the name of your database
PS: delete all " in your syntax (;
Here is the link to the official documentation: https://docs.chain.link/docs/connecting-to-a-remote-database/

How to connect a Firebird data base with Knime?

I need connect my Firebird data base (.IDB) in KNIME. I used Database Connector node, but I have this notice:
ERROR Database Connector 0:1 Execute failed: Could not create
connection to database: Invalid connection string
C:\Users\miPC\Desktop\DataBase1.IDB, reason: null or empty database
name in connection string
The error suggest that you have used the following connection string:
jdbc:firebirdsql://C:\Users\miPC\Desktop\DataBase1.IDB
That is incorrect as it is missing the host name. The correct URL would be:
jdbc:firebirdsql://localhost/C:\Users\miPC\Desktop\DataBase1.IDB
Please consult the Jaybird FAQ for valid URL formats.

Facing Issue Mongo DB ConnectionString

Can Any body tell me how to write a connection string for MongoDB if credentional are as follows:
Database Name - ABC,
Server Name - DEF1,DEF2
UserName - ankur
Password - ankur123
I have Created at My End below
mongodb://ankur:ankur123#DEF1:27017,DEF2:27017/ABC?maxpoolsize=250;authSource=$external;authMechanism=PLAIN;safe=true
But the following error occurs:
Exception: MongoDB.Driver.MongoConnectionException: Unable to connect
in the specified timeframe of '00:00:30'.

MMS Cannot connect to local machine for backup purposes

I am trying to use mongoDB MMS backup functionality. I am getting the following error when trying to connect in the "Add Host" part of the wizard.
Unable to detect host within check interval.
I have MongoDB 2.6.4 on a my Windows 7 laptop. I've created an admin user with the following privileges:
> db.createUser(
... {
... user: "admin",
... pwd: "xxx"
... roles: [
... "clusterAdmin",
... "readAnyDatabase",
... "dbAdminAnyDatabase",
... "userAdminAnyDatabase"
... ]
... }
... );
I run mongod --auth.
Now I try to connect via MMS using MONGODB-CR Auth mechanism and get the error I described above.
In the log I get many errors like the following:
[2014/10/21 09:13:59] [monitoring.info] [monitoring-agent/components/agent.go:551]
Starting 2 marshal handlers
[2014/10/21 09:14:21] [monitoring.error] [monitoring-agent/components/agent.go:314]
Failed to fetch Conf
Failure getting conf. Op: Get Err: dial tcp [I've hide the IP]:443: ConnectEx tcp:
A connection attempt failed because the connected party did not properly respond after
a period of time, or established connection failed because connected host has failed
to respond.
at monitoring-agent/components/conf.go:249
at monitoring-agent/components/agent.go:312
at mongodb.com/monitoring-agent/monitoring-agent-service.go:129
at winsvc/svc/service.go:200
at pkg/runtime/proc.c:1445
Using Robomongo 0.8.4 client I was able to log-in using the user and pass.
I want to be able for MMS to connect to my local machine and initialize a backup of the databases on my machine.
Thanks in advance.
I had this error while configuring my mongodb-mms. On my Ops Manager server I had configured my TLS connections correctly, but on the mongo server being monitored I had the incorrect TLS certificate. The log /var/log/mongodb-mms-automation/monitoring-agent.log on the agent I was trying to monitor helped me out:
[2020/04/26 02:05:47.363] [discovery.collector-mongo2:27017.error] [components/discovery.go:contexts:580] Discovery commands requiring authentication will be skipped.
Failed to get connectionStatus. Err: `auth error: round trip error: (UserNotFound) Could not find user "CN=mms,OU=TestClientCertificateOrgUnit,O=TestClientCertificateOrg,L=TestClientCertificateLocality,ST=TestClientCertificateState,C=US" for db "$external"`
at monitoring-agent/components/dialing.go:442
at monitoring-agent/components/dialing.go:200
at monitoring-agent/components/dialing.go:306
at monitoring-agent/components/dialing.go:323
at louisaberger/procexec/concurrency.go:45
at src/runtime/asm_amd64.s:1357
See this page to add in your mms user so that the user can authenticate correctly (or fix your certs if it's just a mixup).