I am facing a problem connecting to mongodb from my machine to public IP server on which mongodb installed as a windows service with --auth
When I removed authentication as below command, I am able to access the database collection
mongod --install --noauth --dbpath "c:\mongodb\data" --logpath
"c:\mongodb\logs\log.txt" --bind_ip "0.0.0.0"
And when I use the --auth in place of --noauth, I am getting the following error:
errmsg : "auth failed" code :18 login failed
And I am giving correct login details to connect to the mongodb.
What is causing this and how can I fix it?
What command are you using to connect to your database?
If you use mongo like mongo -u login -p password -h xxx.yyy.zzz.aaa try to add --authenticationDatabase admin.
Related
The problem is, Iam installing Mysql Server to run the workbench because otherwise, I cannot open the connection, I get the following error: "Failed to connect MySQL at 127.0.0.1 with user root"
but when I am installing the MySQL server I cannot start the docker.
Both of them are in 3306. Can it be a problem?
I am trying to connect Azkaban ( A job scheduler for hadoop) with my local mysql. The configiration file of azkaban looks like:
database.type=mysql
mysql.port=3306
mysql.host=localhost
mysql.database=azkaban
#Changed by Prakhar for azkaban , Azkaban
mysql.user=root
mysql.password= [ Password of mysql ]
My MySql has a database named "azkaban" and i am able to login mysql using command:
./mysql -u root -p
Also mysql is working on port 3306, which i have verified.
Still i am unable to connect to mysql. The logs of azkaban looks like this:
2020/04/11 22:38:05.584 +0530 ERROR [MySQLDataSource] [Azkaban] Failed to find write-enabled DB connection. Wait 15 seconds and retry. No.Attempt = 1
java.sql.SQLException: Cannot create PoolableConnectionFactory (Could not create connection to database server.)
at org.apache.commons.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:2294)
at org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2039)
at azkaban.db.MySQLDataSource.getConnection(MySQLDataSource.java:76)
at org.apache.commons.dbutils.AbstractQueryRunner.prepareConnection(AbstractQueryRunner.java:175)
at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:286)
at azkaban.db.DatabaseOperator.query(DatabaseOperator.java:68)
at azkaban.executor.ExecutorDao.fetchActiveExecutors(ExecutorDao.java:53)
at azkaban.executor.JdbcExecutorLoader.fetchActiveExecutors(JdbcExecutorLoader.java:266)
at azkaban.executor.ExecutorManager.setupExecutors(ExecutorManager.java:223)
at azkaban.executor.ExecutorManager.<init>(ExecutorManager.java:131)
at azkaban.executor.ExecutorManager$$FastClassByGuice$$e1c1dfed.newInstance(<generated>)
at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:111)
at
Few pointers that might help you to resolve the issue.
Please check the version of MySQL installed vs the MySQL client mentioned in the Gradle file used to build Azkaban
Preferably use MySQL 5.x version
Make sure to install the compatible client version
Also, create the Mysql tables in the database before starting the web executor
So i have production server that i want to connect to with Mysql Workbench.
When i start application all runs fine, so i conenct to it via IP of the server and credentials.
My docker-compose looks like this :
...
workaround-mysql:
container_name: workaround-mysql
image: mysql
environment:
MYSQL_DATABASE: workaround
MYSQL_USER: someuser
MYSQL_PASSWORD: somepass
MYSQL_ROOT_PASSWORD: somepassss
MYSQL_ROOT_HOST: %
ports:
- "3308:3306"
restart: always
....
So on my prod machine i run spring application, mysql, nginx.
When i try to connect via workbench this is the error i get :
Error 10061.
I dont understand what im doing wrong. I had no trouble when i was doing local testing. Workbench worked fine.
Is there some additional settings i have to do ? And can i do these required settings via docker-compose?
On my firewall, i have set accept connection to mysql port:
Oh and the additional note : I get that error right when i press connect on workbench, I dont even have prompt to enter password.
And docker compose up output for mysql part :
Maybe it is just a typo, but you put 3308 as a port in your docker-compose file. So either fix that to 3306 or use 3308 when connecting.
I want to connect to Google Cloud Bigtable which running on Docker:
docker run --rm -it -p 8086:8086 -v ~/.config/:/root/.config \
bigtruedata/gcloud-bigtable-emulator
It starts without any problems:
[bigtable] Cloud Bigtable emulator running on 127.0.0.1:8086
~/.config it is my default credentials that I configured in this way:
gcloud auth application-default login
I used Java-code from official sample HelloWorld.
Also, I changed connection configuration like this:
Configuration conf = BigtableConfiguration.configure("projectId", "instanceId");
conf.set(BigtableOptionsFactory.BIGTABLE_HOST_KEY, "127.0.0.1");
conf.set(BigtableOptionsFactory.BIGTABLE_PORT_KEY, "8086");
conf.set(BigtableOptionsFactory.BIGTABLE_USE_PLAINTEXT_NEGOTIATION, "true");
try (Connection connection = BigtableConfiguration.connect(conf)) {
...
And I set BIGTABLE_EMULATOR_HOST=127.0.0.1:8086 environment variable in a configuration for my app in IntelliJ Idea.
But when I run my Java app, it gets stuck on admin.createTable(descriptor); and shows this log:
...
16:42:44.697 [grpc-default-executor-0] DEBUG
com.google.bigtable.repackaged.io.grpc.netty.shaded.io.netty.util.Recycler
- -Dio.netty.recycler.ratio: 8
After some time it shows log about BigtableClientMetrics and then throws an exception:
java.net.NoRouteToHostException: No route to host
I get the same problem when trying to run Google Cloud Bigtable with my own Dockerfile.
When I run Google Cloud Bigtable with this command:
gcloud beta emulators bigtable start
my app completed successfully.
So, how to solve this problem?
UPDATE:
Now I have this exception:
io.grpc.StatusRuntimeException: UNAVAILABLE: Network closed for unknown reason
and before this another exception is thrown:
java.io.IOException: Connection reset by peer
Need to validate the user authentication in DB2 from Java before creating ant Database or executing any SQL query.
Is there any DB2 command for this?
Thanks in Advance.
You can use this command to run on db2cmd to verify the user name
db2icrt <db2_instancename> -u <userName> , <passWord>
But how to use this from Java, i have no idea.
You can use DB2Jcc - IBM Data Server Driver for JDBC and SQLJ diagnostic utility to test database connectivity and validate DB2 authentication using Java. A sample command and it's output is shown as below:
$ java com.ibm.db2.jcc.DB2Jcc -url jdbc:db2://myhost.bluemix.net:446/MYDB -user myuserid -password mydbpasswd
[jcc][10521][13706]Command : java com.ibm.db2.jcc.DB2Jcc -url jdbc:db2://myhost.bluemix.net:446/MYDB -user myuserid -password ********
[jcc][10516][13709]Test Connection Successful.
DB product version = DSN11015
DB product name = DB2
DB URL = jdbc:db2://myhost.bluemix.net:446/MYDB
DB Drivername = IBM Data Server Driver for JDBC and SQLJ
DB OS Name = Linux
$