Create admin user MongoDB not possible - mongodb

When I am trying to follow the tutorial by typing
mongod --port 27017 --dbpath /data/db1
console responds with
C:\WINDOWS\system32>mongod --port 27017 --dbpath /data/db1
2017-03-03T14:43:54.019+0100 I CONTROL [initandlisten] MongoDB starting : pid=1776 port=27017 dbpath=/data/db1 64-bit host=Tim-V5
2017-03-03T14:43:54.020+0100 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2017-03-03T14:43:54.021+0100 I CONTROL [initandlisten] db version v3.4.2
2017-03-03T14:43:54.021+0100 I CONTROL [initandlisten] git version: 3f76e40c105fc223b3e5aac3e20dcd026b83b38b
2017-03-03T14:43:54.022+0100 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2017-03-03T14:43:54.023+0100 I CONTROL [initandlisten] allocator: tcmalloc
2017-03-03T14:43:54.023+0100 I CONTROL [initandlisten] modules: none
2017-03-03T14:43:54.023+0100 I CONTROL [initandlisten] build environment:
2017-03-03T14:43:54.023+0100 I CONTROL [initandlisten] distmod: 2008plus-ssl
2017-03-03T14:43:54.024+0100 I CONTROL [initandlisten] distarch: x86_64
2017-03-03T14:43:54.024+0100 I CONTROL [initandlisten] target_arch: x86_64
2017-03-03T14:43:54.025+0100 I CONTROL [initandlisten] options: { net: { port: 27017 }, storage: { dbPath: "/data/db1" } }
2017-03-03T14:43:54.025+0100 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db1 not found., terminating
2017-03-03T14:43:54.026+0100 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-03-03T14:43:54.026+0100 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-03-03T14:43:54.027+0100 I CONTROL [initandlisten] now exiting
2017-03-03T14:43:54.027+0100 I CONTROL [initandlisten] shutting down with code:100
Even I already have created folder with
mkdir C:\data\db
and checked that it exists!
Following with
mongo --port 27017
It responds with
MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017/
MongoDB server version: 3.4.2
Server has startup warnings:
2017-03-03T10:02:59.647+0100 I CONTROL [initandlisten]
2017-03-03T10:02:59.647+0100 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-03-03T10:02:59.647+0100 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-03-03T10:02:59.647+0100 I CONTROL [initandlisten]
I am using windows 10, how can I solve this? It's rather frustating

Related

How do I change mongodb data directory on windows

My MongoDB server was running fine until yesterday. But then I encountered this error:
2020-03-31T10:21:25.981+0530 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-03-31T10:21:25.986+0530 I CONTROL [initandlisten] MongoDB starting : pid=7544 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-IP084D8
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] db version v4.2.3
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] allocator: tcmalloc
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] modules: none
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] build environment:
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] distmod: 2012plus
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] distarch: x86_64
2020-03-31T10:21:25.987+0530 I CONTROL [initandlisten] target_arch: x86_64
2020-03-31T10:21:25.988+0530 I CONTROL [initandlisten] options: {}
2020-03-31T10:21:25.990+0530 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating
2020-03-31T10:21:25.990+0530 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-03-31T10:21:25.990+0530 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-03-31T10:21:25.990+0530 I CONTROL [initandlisten] now exiting
2020-03-31T10:21:25.991+0530 I CONTROL [initandlisten] shutting down with code:100
I do not know how the data path got changed. I have to change the MongoDB data path from C:\data\db\ to C:\Program Files\MongoDB\Server\4.2\data, so I tried changing it using the following command, but it doesn't recognize the path:
mongod --dbpath C:\Program Files\MongoDB\Server\4.2\data
What should be the format of the path to be entered here?
Use CMD as a system administrator and type
mongod --dbpath C:\myfolder\myproj\data\db"

How to fix mongodb Error: Network is unreachable

I get this error, when I try to connect to MongoDB
Error:
Network is unreachable.
Running mongod before mongo shell didn't help .
When I restart my computer it works!!!Anyway I get that error again, something like 30 minutes later.
This is output from cmd, when I run command mongod
C:\Program Files\MongoDB\Server\4.0\bin>mongod
2019-04-26T18:50:26.559+0400 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-04-26T18:50:26.562+0400 I CONTROL [initandlisten] MongoDB starting : pid=1092 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-47AK9D5
2019-04-26T18:50:26.562+0400 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2019-04-26T18:50:26.563+0400 I CONTROL [initandlisten] db version v4.0.7
2019-04-26T18:50:26.563+0400 I CONTROL [initandlisten] git version: 1b82c812a9c0bbf6dc79d5400de9ea99e6ffa025
2019-04-26T18:50:26.564+0400 I CONTROL [initandlisten] allocator: tcmalloc
2019-04-26T18:50:26.565+0400 I CONTROL [initandlisten] modules: none
2019-04-26T18:50:26.565+0400 I CONTROL [initandlisten] build environment:
2019-04-26T18:50:26.565+0400 I CONTROL [initandlisten] distmod: 2008plus-ssl
2019-04-26T18:50:26.566+0400 I CONTROL [initandlisten] distarch: x86_64
2019-04-26T18:50:26.566+0400 I CONTROL [initandlisten] target_arch: x86_64
2019-04-26T18:50:26.567+0400 I CONTROL [initandlisten] options: {}
2019-04-26T18:50:26.568+0400 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory C:\data\db\ not found., terminating
2019-04-26T18:50:26.568+0400 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-04-26T18:50:26.568+0400 I CONTROL [initandlisten] now exiting
2019-04-26T18:50:26.568+0400 I CONTROL [initandlisten] shutting down with code:100
Edit: I found a problem. MongoDB Server turns off automatically. Just change service startup type to Manual.
MongoDB Server Properties

Can't set mongo as replica set

Hi I am trying to use mongo-connector for transport data from mongo db to elasticsearch. For that I need to set mongodb as replica set. So I run the mongodb first by executing mongod command and run mongod --replSet "rs0 command after that. But it showed me an error as below.
2017-10-03T21:16:46.571-0700 I CONTROL [initandlisten] MongoDB starting : pid=12180 port=27017 dbpath=C:\data\db\ 64-bit host=ME
2017-10-03T21:16:46.572-0700 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2017-10-03T21:16:46.572-0700 I CONTROL [initandlisten] db version v3.4.6
2017-10-03T21:16:46.572-0700 I CONTROL [initandlisten] git version: c55eb86ef46ee7aede3b1e2a5d184a7df4bfb5b5
2017-10-03T21:16:46.573-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2017-10-03T21:16:46.573-0700 I CONTROL [initandlisten] allocator: tcmalloc
2017-10-03T21:16:46.573-0700 I CONTROL [initandlisten] modules: none
2017-10-03T21:16:46.573-0700 I CONTROL [initandlisten] build environment:
2017-10-03T21:16:46.573-0700 I CONTROL [initandlisten] distmod: 2008plus-ssl
2017-10-03T21:16:46.574-0700 I CONTROL [initandlisten] distarch: x86_64
2017-10-03T21:16:46.574-0700 I CONTROL [initandlisten] target_arch: x86_64
2017-10-03T21:16:46.574-0700 I CONTROL [initandlisten] options: { replication: { replSet: "rs0" } }
2017-10-03T21:16:46.575-0700 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: C:\data\db\mongod.lock The process cannot access the file because it is being used by another process.. Is a mongod instance already running?, terminating
2017-10-03T21:16:46.575-0700 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-10-03T21:16:46.575-0700 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-10-03T21:16:46.575-0700 I CONTROL [initandlisten] now exiting
2017-10-03T21:16:46.576-0700 I CONTROL [initandlisten] shutting down with code:100
Just Run the command directly mongod --replSet "rs0", don't use mongod and then the replSet command.

Unable to start mongdb

2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] MongoDB starting : pid=5716 port=27017 dbpath=/data/db/ 64-bit host=localhost
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] db version v3.2.0
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] git version: 45d947729a0315accb6d4f15a6b06be6d9c19fe7
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] allocator: tcmalloc
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] modules: none
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] build environment:
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] distmod: ubuntu1404
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] distarch: x86_64
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] target_arch: x86_64
2017-05-11T12:03:49.700+0530 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db/" } }
2017-05-11T12:03:49.724+0530 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2017-05-11T12:03:49.724+0530 I - [initandlisten] Fatal Assertion 28578
2017-05-11T12:03:49.724+0530 I - [initandlisten]
***aborting after fassert() failure`enter code here`
I am not able to start Mongodb server i tried using service as well and using --dbpath as well i don't know what is the issue. i tried to delete journal files as well but that didn't work
Try to delete the file /tmp/mongodb-27017.sock manually and restart the process.
Have you tried starting it with Sudo from the terminal like so
sudo mongod
this will require your system username and password

mongo can not connect to mongodb server

I just installed mongodb on windows 10.
The server part
$ mongod --auth --dbpath ./db/
2017-04-26T15:08:27.905+0800 I CONTROL [initandlisten] MongoDB starting : pid=244 port=27017 dbpath=./db 64-bit host=DESKTOP-NK0JQ4S
2017-04-26T15:08:27.906+0800 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2017-04-26T15:08:27.907+0800 I CONTROL [initandlisten] db version v3.4.4
2017-04-26T15:08:27.907+0800 I CONTROL [initandlisten] git version: 888390515874a9debd1b6c5d36559ca86b44babd
2017-04-26T15:08:27.907+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2017-04-26T15:08:27.908+0800 I CONTROL [initandlisten] allocator: tcmalloc
2017-04-26T15:08:27.908+0800 I CONTROL [initandlisten] modules: none
2017-04-26T15:08:27.909+0800 I CONTROL [initandlisten] build environment:
2017-04-26T15:08:27.909+0800 I CONTROL [initandlisten] distmod: 2008plus-ssl
2017-04-26T15:08:27.909+0800 I CONTROL [initandlisten] distarch: x86_64
2017-04-26T15:08:27.909+0800 I CONTROL [initandlisten] target_arch: x86_64
2017-04-26T15:08:27.910+0800 I CONTROL [initandlisten] options: { security: { authorization: "enabled" }, storage: { dbPath: "./db/" } }
2017-04-26T15:08:27.914+0800 I - [initandlisten] Detected data files in ./db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-04-26T15:08:27.915+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3525M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-04-26T15:08:28.795+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory './db/diagnostic.data'
2017-04-26T15:08:28.798+0800 I NETWORK [thread1] waiting for connections on port 27017
2017-04-26T15:08:34.860+0800 I NETWORK [thread1] connection accepted from 127.0.0.1:59658 #1 (1 connection now open)
The connection part
$ mongo
MongoDB shell version v3.4.4
connecting to: mongodb://127.0.0.1:27017
This just shows that it is connecting to MongoDB, but can not connect to the MongoDB server.