"mongod" execution terminates immediately - mongodb

Error that i cant figure out as Im new to using mongoDB... it says that data/db not found and then it terminates..... Do I need to create this folder?
2016-01-27T18:14:41.788+0000 I CONTROL [initandlisten] MongoDB starting : pid=8556 port=27017 dbpath=C:\data\db\ 64-bit host=andrews-hp
2016-01-27T18:14:41.796+0000 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2016-01-27T18:14:41.800+0000 I CONTROL [initandlisten] db version v3.2.1
2016-01-27T18:14:41.803+0000 I CONTROL [initandlisten] git version: a14d55980c2cdc565d4704a7e3ad37e4e535c1b2
2016-01-27T18:14:41.808+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1p-fips 9 Jul 2015
2016-01-27T18:14:41.813+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-01-27T18:14:41.817+0000 I CONTROL [initandlisten] modules: none
2016-01-27T18:14:41.820+0000 I CONTROL [initandlisten] build environment:
2016-01-27T18:14:41.825+0000 I CONTROL [initandlisten] distmod: 2008plus-ssl
2016-01-27T18:14:41.830+0000 I CONTROL [initandlisten] distarch: x86_64
2016-01-27T18:14:41.834+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-01-27T18:14:41.837+0000 I CONTROL [initandlisten] options: {}
2016-01-27T18:14:41.842+0000 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory C:\data\db\ not found., terminating
2016-01-27T18:14:41.849+0000 I CONTROL [initandlisten] dbexit: rc: 100

Yes you do, I have it under C:.
C:\data\db

Related

My MongoDB isnt working when I type mongod in the terminal

I type in mongod to create a new db but I get this error, any idea what's going on here?
mongod
2018-08-28T18:06:36.824+0100 I CONTROL [initandlisten] MongoDB starting : pid=41812 port=27017 dbpath=/data/db 64-bit host=Ruairidhs-MacBook-Pro.local
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] db version v3.6.3
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] allocator: system
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] modules: none
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] build environment:
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] distarch: x86_64
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] target_arch: x86_64
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] options: {}
2018-08-28T18:06:36.825+0100 I STORAGE [initandlisten] exception in initAndListen: DBPathInUse: Unable to lock the lock file: /data/db/mongod.lock (Resource temporarily unavailable). Another mongod instance is already running on the /data/db directory, terminating
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] now exiting
2018-08-28T18:06:36.825+0100 I CONTROL [initandlisten] shutting down with code:100
Open a new terminal window, and execute top, according to the error, you already have an instance of mongod running, so you need to find it and terminate it.

Mongod not finding the path of the data directory

I'm trying to build a simple CRUD app with a MEAN stack, here's my file tree so far:
-app
-node_modules
-server
-config
-db.js
-controllers
-user.api.js
-models
-user.js
-routes
-api.js
-web.js
-package.json
-server.js
When running mongod I got the following error:
2017-12-03T15:25:53.243-0500 I CONTROL [initandlisten] MongoDB starting : pid=57220 port=27017 dbpath=/data/db 64-bit host=Carloss-MacBook-Pro.local
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] db version v3.4.10
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] git version: 078f28920cb24de0dd479b5ea6c66c644f6326e9
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2m 2 Nov 2017
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] allocator: system
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] modules: none
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] build environment:
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] distarch: x86_64
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] target_arch: x86_64
2017-12-03T15:25:53.244-0500 I CONTROL [initandlisten] options: {}
2017-12-03T15:25:53.247-0500 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2017-12-03T15:25:53.247-0500 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-12-03T15:25:53.247-0500 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-12-03T15:25:53.247-0500 I CONTROL [initandlisten] now exiting
2017-12-03T15:25:53.247-0500 I CONTROL [initandlisten] shutting down with code:100
So I tried to specify the path of my folder to /server/config/db but that still didn't work. Am I writing the path incorrectly?
This is what I have in my db file:
var mongoose = require('mongoose');
var connection = mongoose.connect('mongodb://localhost/mean_db');
module.exports = connection;

Getting error on starting mongodb

I tried to start mongoldb and got error like another instance is running. Closed all other instances, but still getting the same error
$ mongod
2017-06-06T14:10:42.318-0400 I CONTROL [initandlisten] MongoDB starting : pid=22652 port=27017 dbpath=/data/db 64-bit host=IML13C02L80WLF8J2.local
2017-06-06T14:10:42.318-0400 I CONTROL [initandlisten] db version v3.4.0
2017-06-06T14:10:42.318-0400 I CONTROL [initandlisten] git version: f4240c60f005be757399042dc12f6addbc3170c1
2017-06-06T14:10:42.319-0400 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2j 26 Sep 2016
2017-06-06T14:10:42.319-0400 I CONTROL [initandlisten] allocator: system
2017-06-06T14:10:42.319-0400 I CONTROL [initandlisten] modules: none
2017-06-06T14:10:42.319-0400 I CONTROL [initandlisten] build environment:
2017-06-06T14:10:42.319-0400 I CONTROL [initandlisten] distarch: x86_64
2017-06-06T14:10:42.319-0400 I CONTROL [initandlisten] target_arch: x86_64
2017-06-06T14:10:42.319-0400 I CONTROL [initandlisten] options: {}
2017-06-06T14:10:42.319-0400 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to lock file: /data/db/mongod.lock Resource temporarily unavailable. Is a mongod instance already running?, terminating
2017-06-06T14:10:42.319-0400 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-06-06T14:10:42.319-0400 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-06-06T14:10:42.319-0400 I CONTROL [initandlisten] now exiting
2017-06-06T14:10:42.319-0400 I CONTROL [initandlisten] shutting down with code:100

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

MongoDB server getting disconnected

I am getting the following error while running mongod in the terminal(Ubuntu 16.04 LTS).
2016-08-16T13:32:14.690+0530 I CONTROL [initandlisten] MongoDB starting: pid=4810 port=27017 dbpath=/data/db 64-bit host=Rohan
2016-08-16T13:32:14.690+0530 I CONTROL [initandlisten] db version v3.2.8
2016-08-16T13:32:14.690+0530 I CONTROL [initandlisten] git version:ed70e33130c977bda0024c125b56d159573dbaf0
2016-08-16T13:32:14.690+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g-fips 1 Mar 2016
2016-08-16T13:32:14.690+0530 I CONTROL [initandlisten] allocator: tcmalloc
2016-08-16T13:32:14.690+0530 I CONTROL [initandlisten] modules: none
2016-08-16T13:32:14.690+0530 I CONTROL [initandlisten] build environment:
2016-08-16T13:32:14.690+0530 I CONTROL [initandlisten] distmod: ubuntu1604
2016-08-16T13:32:14.690+0530 I CONTROL [initandlisten] distarch: x86_64
2016-08-16T13:32:14.690+0530 I CONTROL [initandlisten] target_arch: x86_64
2016-08-16T13:32:14.690+0530 I CONTROL [initandlisten] options: {}
2016-08-16T13:32:14.717+0530 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted
2016-08-16T13:32:14.717+0530 I - [initandlisten] Fatal Assertion 28578
2016-08-16T13:32:14.717+0530 I - [initandlisten]
***aborting after fassert() failure
Why is this happening?
I have fixed this issue myself, by deleting the mongodb-27017.sock file . I ran the service after deleting this file, which worked fine. However, I am still not sure the root cause of the issue. The output of the command ls - lat /tmp/mongodb-27017.sock is now
srwx------ 1 mongodb nogroup 0 Apr 23 06:24 /tmp/mongodb-27017.sock