mongodb instantly stopping after starting - mongodb

A fairly simple question...
mongod in the command line just stopped working?
In the command line i start up mongod like i used to and it doesn't start and just goes straight back to the command line:
username:~ computer$ mongod
all output going to: /usr/local/var/log/mongodb/mongo.log
username:~ computer$
Tried in terminal mongod --repair and nothing happens... it just waits longer before going back to the normal username:~ computer$
Why is this broken now?... how do i figure out what went wrong? So confused.
I'm trying to uninstall mongodb and re-install... even that is hard... how to you uninstall it in terminal?
ER

This cmd seems to have fixed it:
$ mongod --repairpath arg

For start mongod you need parameter -dbpath -logpath mandatorily or configure all parameters in /etc/mongod.conf and run with root user
If you run mongo shell, in console typing mongo, not mongod, mongod launch mongo process, mongo is for access to shell.
If you need unistall mongo, only need delete all mongo files in /user/bin or path where unzipped the pack mongo

Related

Mongod not working in terminal, trying to reassign alias

I am using Mac Monterey
When I type mongod in the terminal, I get the shutting down exitCode:100 error.
I can reassign mongod with alias mongod="sudo mongod --dbpath /usr/local/data/db, then mongod works after I type in my password, it does not work if I do not add sudo.
If I do not add sudo, I get the aborting after fassert() failure error.
After restarting the terminal, I have to reassign mongod again otherwise I get the exitCode:100 error again
I tried to re-assign mongod with alias mongod="sudo mongod --dbpath /usr/local/data/db in the .bash_profile file using vim.
Then mongod works, but only for that one session... if I restart the terminal, then I have to re-assign it again.
I tried re-assigning it in the .bash_profile... but I think I might be doing it wrong or something
can someone please help with this?
I found the problem, all the comments on google says to use a .bash_profile to update the mongod file path, however I found that I was supposed to update the file path in a .zprofile file as I'm using zsh and not bash

Unable to configure mongoDB

Im learning mongoDB and exploring its features, i try several commands when i run the terminal and mongod acts like does not care. It always starts the server even though i simply run for reading help.
Some commands that i run
mongod --help
mongod --port 5000
mongod --dbpath C:\myfolder\myproj\data\db
Everytime, no matter witch i run from the above commands it starts the server always even when searching for help. The port and path do not change also, it looks like it ingores everything other than the mongod in the terminal. Any help?
mongod starts the service, but when you close the terminal then also the service terminates.
However, usually you install mongod as a Service. See mongod.exe for details.
Maybe this package will help you: mongoDB-oneClick

Cannot start mongodb server

I'm following this tutorial, as well as this one, and I keep getting the same error when starting up my mongodb server.
Running just mongo returns
zsh: command not found: mongod
Running ./mongod returns
zsh: exec format error: ./mongod
Running sudo ./mongod returns
./mongod: ./mongod: cannot execute binary file
My mongodb folder is located in ~/mongodb, which is where the bin folder is. I also created the directory where Mongo will store the data in /data/db, with the correct permissions: drwxr-xr-x. I don't know what I'm missing, or what I'm doing wrong.
How do I start the mongodb server?
Solved
I was using the wrong OS. I downloaded the linux version when I should have downloaded the OS X version since I'm on a Mac. Once I did, everything worked fine.
Much more robust is if you start it as a service with sudo service mongod start
Alternatively, you need to make sure the directory is added to .bashrc.
try this command. It worked for me in git bash
./mongod.exe --port <port number> --dbpath <db folder path>
Ex:
./mongod.exe --port 27017 --dbpath E:/Projects/Databases/data/db
Most likely the path to your MongoDB is not within your $PATH. If you are on linux you can quickly run:
echo $PATH
If it is not in your path, then you want to add it:
export PATH=/path_to_mongodb_bin/:$PATH
Once done, attempt to start mongodb by running:
mongod

mongo: failed to connect to server [localhost:27017]

what can I do to solve this problem? I'm on windows so I can't run sudo mongo I tried to do "runas" in windows instead of linux "sudo" but it didn;t help me out. I was looking for a fle called monogod.lock to remove it but didn't find something like that...I tried mongo repair but it also didn't help me...help someone?
btw...I tried to start mongo.exe from it's directory in another CMD but it failed also:
Seems you have not started the Mongo DB Server.
Do the followings.
In Windows, start Command Prompt.
Run mongod.exe to start Mongo DB Server.(This will work only if your environment variable PATH contains the bin directory of your Mongo DB installation)
Open another Command Prompt and start client by running mongo.exe.
Check this link which might help you.
MongoError: failed to connect to server [localhost:27017] on first connect
oh guys I finally got that! when you run mongod.exe on windows you should also give it the path of the directory if not it won't work! if somehow you'll have a mongod.lock on your directory you should delete this file than write on CMD mongod.exe repair and start running it again! thanks to all =]
In linux
1.- In the terminal
$ sudo systemctl start mongodb
$ mongo

getting an error when firing up mongodb in terminal [duplicate]

I'm getting the following error when I try to run "mongod" in the terminal. I've tried uninstalling, reinstalling, and restarting the machine. Any suggestions on how to get it working would be amazing.
ERROR:
dbpath (/data/db) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
Side note:
Node also stopped working on my machine around the same time that I got this error.
events.js:72
throw er; // Unhandled 'error' event
^
Error: failed to connect to [localhost:27017]
Any help would be much appreciated!
This should work to ensure that the directory is set up in the right place so that Mongo can find it:
sudo mkdir -p /data/db/
sudo chown `id -u` /data/db
You need to create the directory on root /data/db or set any other path with the following command :
mongod --dbpath /srv/mongodb/
See the example link
I solved the problem with :
sudo mongod --dbpath=/var/lib/mongodb and then mongo to access the mongodb Shell.
Change the user of the new data directory:
chown mongodb [rute_directory]
And try another time to start the mongo service
service mongod start
I solve the same problem with this.
Daemons (usually ending with d) are normally started as services. Starting the service (daemon) will allow mongodb to work as designed (without permission changes if integrates well with your distro). I start it using the service named mongodb instead of starting mongod directly--on distro with systemd enable on startup then run like:
sudo systemctl enable mongodb
sudo systemctl start mongodb
or, on distro with upstart (if you have /etc/init) or init (if you have /etc/init.d) ( https://www.tecmint.com/systemd-replaces-init-in-linux/ ) instead run:
sudo service mongodb enable
sudo service mongodb start
If you have a distro with rc ("run commands") such as Gentoo (settings in /etc/init.d) (https://forums.gentoo.org/viewtopic-t-854138-start-0.html) run:
rc-update add mongodb default
/etc/init.d/mongodb start
In a distro/version of FreeBSD which still has rc (check whether your version switched to systemd, otherwise see below):
add the following line to /etc/rc.conf:
mongod_enable="YES"
then:
sudo service mongod start
After starting the service, an unpriveleged user can use mongo, and each user will have separate data.
I also got the error that "The file /data/db doesn't exist" when I tried to save my file using the "mkdir -p /data/db" command(using both with and without sudo command). But later on one site, a person named Emil answered that the path "/data/db" no longer works on Mac, so use "~/data/db" instead
i.e., use the command
mkdir -p ~/data/db
instead of previous command.
Moreover, use
mongod --dbpath ~/data/db
to run mongod
It worked for me, hope it work for others too facing the same problem