Why does MongoDB require launching mongod.exe before connecting to DB? - mongodb

MySQL, for example, does not require this. Why MongoDB does?
The problem:
I'm writing an app (for PC) in Java that uses MongoDB. I downloaded a driver (3rd version, the newest) and everything is fine...
...except for the need to launch mongod.exe to actually use a database.
In terms of app, it is extremely user-unfriendly. So in order to use my app, he will need to launch mongod.exe first, and even if it's done automatically by my app (via using runtime), user will still have 2 windows.
Moreover, instead of seeing just my app icon on taskbar.
How it should be:
User will see my app icon and mongod icon:
How it is:
Is there any solution to that? If not, can somebody explain why do we need to start mongod at all? It's very poor design from MongoDB devs, for example when using MySQL your Java app can connect to databases directly, without running any other software that is displayed on taskbar.
If apps that use MongoDB will require from user to launch mongod beforehand, or even if they do it themselves but there are 2 icons on the taskbar and that large black window of mongod running, it would be totally unfriendly to user so there would be no sense to use Mongo.

Mongod is mongoDB server application! without running it there's nothing back there listening to your requests!
Regarding to MySQL, you probably set it as a windows service and windows automatically runs mysqld.exe at windows start up! otherwise you would need to run mysqld.exe too!

Related

I am not able to start MongoDB ON WINDOWS 10

Mongod is not starting on windows 10 it shows 'access control is not enabled for the database. Read and write access to data and configuration is unrestr 10.
Mongo is started and is running. This message is simply a notice, not an error. It says that your Mongo database is insecure because anyone is able to read and write. This is fine for your development purposes on your computer, but you should change the settings if you use Mongo for a production, customer-facing website.

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.

Can't run "meteor mongo" on Meteor in Windows (latest meteor for windows exe bootstrapper)

I am trying to run a meteor app for the first time on Windows( using Windows 7 in particular). I am able to successfully run the app but i can't seem to be able to run the command meteor mongo in a separate command prompt window. The following error pops up:
mongo: Meteor isn't running.
This command only works while Meteor is locally. Start your
application first.
I have already tried meteor reset. How can i fix this?
I think there is possible a misconception about what the meteor mongo command does.
It only connects to the mongo instance of a running meteor development process.
So you need to start the meteor app by changing to your app's directory and running 'meteor'. Then on a different console window, change you the same directory and run 'meteor mongo'.
In the image below, when meteor isn't running I get the error you get, but you will note that it says that you have to start your application first. If you do that, and then in another console window it works:
Try one of these admin UIs for mongo instead. They connect directly to the db, so should overcome whatever problem there is with command line.
Alternatively, you may try a non-standard command line utility, like Cygwin.

Starting mongo then leaving shell without shutting down the server

Hi Guys I start Mongo remotely on Putty SSH and after mongod, it says "listening for ports" but I can't then leave without shutting down the server. how do I do that?
On linux, look up the Screen module. There are other alternatives that do the same thing as well. It basically makes a saved session that you can reattach to later -- I use it extensively to run long tests/services that I can reattach to quickly.
The Starting and Stopping Mongo documentation article explains several options, one of which is using the --fork command line parameter to start mongod as a background process. Additionally, you can look into using service controls provided by your operating system (e.g. Windows services, init.d, upstart).
You can make a quick Mongo service script in either Windows or Linux.
You can also press CTRL+Z which will basically switch it to a background process. This basically gives you back temrinal (or at least does for me).
I also like "Screen". It is quite powerful and easy to navigate so I would personally give that a try.

Hard to think of a reason why MongoDB doesn't create /data/db for us automatically?

I installed MongoDB both on Win 7 and on Mac OS X, and both places, I got mongod (the server) and mongo (the client).
But at both places, running mongod will fail if I double click on the file, and the error message was gone too quickly before I can see anything. (was better on Mac because Terminal didn't exit automatically and showed the error message).
Turned out it was due to /data/db not exist and the QuickStart guide says: By default MongoDB will store data in /data/db, but it won't automatically create that directory
I just have a big question that MongoDB seems to want a lot of people using it (as do many other products), but why would it not automatically create the folder for you? If it didn't exist... creating it can do not much harm... especially you can state so in the user agreement. The question is why. I can think of one strange reason, but the reason may be too strange to list here...
One good reason would be that you do not want it in /data/db. In this case, you want it to fail with an error when you forgot to specify the correct directory on the command line. The same goes for mis-spelled directory names. If MongoDB just created a new directory and started to serve from there, that would not be very helpful. It would be quite confusing, because databases and collections are auto-created, so there would not even be errors when you try to access them.