mongo' is not recognized as an internal or external command, operable program or batch file - mongodb

mongo is not recognized as an internal or external commandmongodb is not recognized as an internal or external commandI'm encountering these errors after having installed mongodb using a tutorial and after having tried the edit environment variables fix.I've edited the environment variables The mongosh keyword is recognized when I type it in in the command line but mongo and mongodb aren't. Mongod results in something I'm not certain it should be resulting in.is this expected? I noticed that the number of files available in my bin folder which is where mongodb is installed is less than that of others that I've seen.this is my bin folder with less files I also noticed that after installing mongodb, the mongo compass didn't auto install. I did that manually. How can I overcome these errors and start using mongodb?

mongod is the binary that runs the database. It has many flags, documented here. The output you see is expected. You will often run this in the background via --fork and send the output to a logfile.
mongo is the legacy shell that is deprecated as of 6.0 and no longer ships.
mongosh is the new shell that should provide all the same functionality as the legacy shell.
mongodb there is no binary with this name.
If you are trying to connect to MongoDB Atlas or an existing database, you should not need to run mongod yourself.

Related

Error "'mongodump' is not recognized as an internal or external command, operable program or batch file." trying to dump the database from mongodb 5.0

I am trying to dump a database from mongodb where i am getting not recognized error on running the command from command line as admin.
mongodump --db ninjago,
I have added the path variable in environment variables for mongodb. I am still getting the error.
Please help. thanks
You have to additionally install MongoDB Database Tools in order to use mongodump in the CLI. If you need to restore the data, after installing MongoDB Database Tools you will be able to use the mongorestore in the CLI as well.
You can download the MongoDB Database Tools on official MongoDB download page, and then you can follow the official installation guide.

Shell logging for mongodb

I am new to mongodb and trying to figure out a lot.
Can we configure shell logging for mongodb? What I mean is the capability to get logs from the Shell to track queries for auditing purposes for version 4?
If so - what commands do we have to run please?
Thank you for your help
There are two versions of MongoDB shell: the newer mongosh and the older/legacy mongo shell.
mongo maintains a history of commands in the .dbshell file. For example, in the Windows 7 environment this can be found at the folder: C:\Users\<user_name>
MongoDB Shell mongosh stores logs for each session and can be retrieved as explained at: Retrieve Shell Logs. For example, in Windows environment this can be found at the folder: C:\Users\<user_name>\AppData\Local\. The log files are of the format <LogID>_log.

Mongo db trying to create restorable backup

I got databse with name "test" in mongoatlas.
I installed mongodb with
mongodb-windows-x86_64-4.4.1-signed.msi
I run this command and it does not shows my test db. I'm trying to make backup my db
show dbs
admin 0.000GB
config 0.000GB
local 0.000GB
I watched tutorial to how to backup&restore in mongodb. So I run the command
mongodump
It says
'mongodump' is not recognized as an internal or external command,
operable program or batch file.
but I can run mongo and mongod command. I gave a path to run mongodb in cmd to environment variables
Also they say in the docs use mongodump command in cmd. I tryed it with administrator mode and it still gives same think.
So how can I backup& restore dbs. Thank you
mongodump is part of the mongo database tools, these tools are not automatically installed when your install certain Mongo server bundles.
As in your case, your cmd line does not recognise this command because it was never installed on your machine.
Follow the instructions here in order to install it.
Access the MongoDB Download Center
Select your Platform from the dropdown menu, then select the following Package for your platform:
Once downloaded, unpack the archive and copy the tools to a location on your hard drive.
You will have to set the MongoDB install path in your Path environment variables
For eg :
My mongoDB is installed at C:\Program Files\MongoDB\Server\4.0\bin
In environment variables i should have,
Also make sure you have installed mongodb properly. You should have following set of exe/files

How do you convert mongod to mongo service?

I have been running MongoDB on two Windows 10 PCs. However, one has mongo always running it seems where I only need to open command prompt and type mongo. This gives me access to the db on PC #1.
However, on PC #2, I must open command prompt and type mongod. Then I have to open a second command prompt to type in mongo, then I get access to the db on PC #2.
After doing this for about a year, I find I want to just want both PCs to work like PC #1, where I just type in mongo and not mongodb and only have to use one command prompt.
I checked online but there's nothing I found straightforward to accomplish this specifically.
Does anybody know the answer?
If in PC#2, your MongoDB version is < 4.0, then you can't do anything i.e., you have to continue with mongod to start Mongo as you do now.
But if your MongoDB version is >= 4.0 or you want to upgrade from lower version of MongoDB, you can follow the below steps.
Take backup of all databases with mongodump. If it is large volume data, then go through this.
Uninstall your MongoDB using Windows Uninstall Program features.
Reinstall MongoDB using the link.
While installing, ensure you select 'MongoDB Service' feature.
Start the MongoDB now in PC#2 as you do in PC#1.
Restore the old databases with mongorestore.

How to run a mongod instance

I am a starter of MongoDB. According to the "Import Example" section of MongoDB 3.2 Manual, the prerequisite for importing data into the database is to have a running mongod instance. With limited background knowledge of MongoDB, I failed to fully understand this line of instruction. Could anyone please give me some explanation on how to run a mongod instance step by step in Mac Terminal? Thanks.
Here are several steps to do start mongodb var mongod
created the ./bin/data/db directory storing mongodb data file.
Start one terminal for mongodb server
Go to mongo/bin, and execute this command
./mongod
Start another terminal for mongodb shell
Go to mongo/bin, and run
./mongo
Now we can connect to mongodb now, more command like show dbs, show collections, use dbname, For more commands in mongodb, refer to db.help()...