I installed MongoDB manually on the MongoDB website. https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
I followed the instructions under "Install MongoDB Community Edition Manually".
How do I uninstall MongoDB completely? I have searched around and only found how to uninstall using Homebrew. I did not install MongoDB using Homebrew.
Any help is greatly appreciated.
Just follow the manual install steps in reverse order:
shutdown mongod
remove your data directory (if you no longer want this)
remove the directory with the MongoDB binaries
remove the directory with the MongoDB binaries from your shell PATH
Other files that might have been created depending on how you ran MongoDB:
there may be old log files to remove if you specified a --logpath outside your data directory
there may be a launchctl script and configuration file to remove if you configured mongod to run as a service
Related
I have downloaded the .msi multiple times and tried to run in a variety of ways, however, I cannot install MongoDB on my windows 10 machine. When I click the .msi, I get the first "preparing to install" pop-up and then it just goes away. Nothing happens.
I tried downloading the zip folder which contains a bunch of .exes.. but still nothing. I'm not sure how to get this to work on my local.
Thoughts?
For some reason, the latest documentation doesn't include the manual installation process.
Download the distribution ZIP and extract it to c:\mongodb\ or equivalent.
Then from the resultant bin directory you can run an administrative powershell command (be sure to replace the paths with real paths that exist on your system):
PS C:\mongodb\bin> ./mongod.exe --install --logpath="c:\\path\\to\\logfile.log" --dbpath="c:\\path\\to\\data\\on\\disc"
This will create a windows service named "MongoDB" which should start automatically. If it doesn't, you can run net start MongoDB from your admin PS prompt.
Please download Mongodb from there official sites and also there is a very easy guide to install the mongodb on various OS.
Reference:- https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/
I run a MongoDB replica set in a containerization environment orchestrated by Rancher.
After rolling out the latest update, MongoDB as been upgraded from 3.6.x to 4.0.x (latest).
No upgrade path has been followed and, as a result, when trying to bind the volume holding the database storage, the service fails to start, exiting with the following exception:
STORAGE [initandlisten] exception in initAndListen: MustDowngrade: Collection does not have UUID in KVCatalog. Collection: admin.system.version, terminating
I get the same outcome even attempting to launch mongod with the --repair option.
I have also tried to rollback the container to MongoDB 3.6.16, but the journal version is now incompatible.
We don't have snapshots of the volume, hence restoring the data is not an option (this is not a production environment). The only solution I've found online is not applicable, since it suggests to leverage mongodump and mongorestore, requiring a running database with the data storage attached.
I'm running out of ideas, any advice about how to fix this?
A bug report on this issue recommended following the full upgrade path and that worked for me. I was able to go back to my old version when I ran into this error, and then upgrade properly.
Specifically: upgrade just one major version at a time and check the prerequisites and upgrade steps carefully. The most important part of this is checking your compatibility with db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } ) and make sure it matches the current version before upgrading to the next version. Update it with command like db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
Read the full docs at pages like https://docs.mongodb.com/manual/release-notes/3.6/#upgrade-procedures https://docs.mongodb.com/manual/release-notes/4.0/#upgrade-procedures etc
I was updating MongoDB from 3.6 to 4.2 with Homebrew on Mac OS, and ran into this similar situation.
Since formula mongodb was removed from homebrew-core, the team of mongodb maintained a custom Homebrew tap.
Following steps is my solution for upgrading MongoDB from 3.6 to 4.2 with Homebrew:
Uninstall old version mongodb from Homebrew
# If you run mongodb in background service, stop it first.
brew services stop mongodb
# If you have multiple version of mongodb, you might need to add `--force` option for deleting all of them at once.
brew uninstall mongodb
Install new mongodb from custom Homebrew tap
brew tap mongodb/brew
brew install mongodb-community#3.6
Add mongodb-community#3.6 to your PATH
echo 'export PATH="/usr/local/opt/mongodb-community#3.6/bin:$PATH"' >> ~/.bash_profile
Restart your terminal, and run mongod
Open another tab or terminal windows to run mongodump
Terminate mongod
Uninstall mongodb-community#3.6 and reinstall mongodb-community
brew uninstall mongodb-community#3.6
brew install mongodb-community
Delete old data with old mongo data structure
rm -rf /data/db/*
Run mongod
Open another tab or terminal windows to run mongorestore dump/
Once mongorestore completed, mongod will be terminated.
And you can run mongodb as a background service or just run mongod again. Open MongoDB with mongo or Robo 3T(formerly Robomongo), you will see your data is good as usual.
Hope it helps.
Alright after about 3hours of trying to fix exactly what you are describing, here are the steps I took. Here I will show how to retain the data while downgrading to 3.6 and also how to update it 4.0 with the retained data.
The reason this happens for mac users is because there was an update for people using brew can no longer download Mongodb directly from brew. Then people tend to download the newer community edition instead from brew which then gets in conflict the old version of 3.6 db folder still present in the directory. Instead you would need to download it from the actual mongodb website:
https://www.mongodb.com/download-center/community
Here what you would want to do, is download everything manually. Follow these instructions here, but do this with the 3.6 version:
https://medium.com/#saurabhkumar_4718/install-mongodb-without-homebrew-on-mac-os-2a98b68ab09c
NOTE: when you copy .bash_profile please make sure export commands are not
Once you have successfully installed 3.6 manually you can mongodump to be safe, and or export all your mongo data into json with mongoexport for any data that you must really really save.
After that you can fresh install 4.0 manually again by following exactly the same steps as previously done for 3.6
This worked for me without having to do any 'mongorestore' as the 'db' folder was left alone and all my data was there, but maybe extra steps might be needed to restore the data. Worst comes to worst you have .jsons that needs to be rewritten. 'mongo --version' also showed the right version :) Hope it helps
Backing-up all the databases (using mongodump)
Removing every file in /data/db, due to their incompatibility with the newer version: rm -rf /data/db/*
Restarting the MongoDB service by mongod
Restoring all the databases (using mongorestore)
https://dba.stackexchange.com/a/252393
For Docker:
I had this issue when I was upgrading a project that used Docker from 3.6 to 4.2 (and 4.4).
The way the project is set up means I don't have a physical /data/db directory to purge.
However, there is a volume defined that acts as the /data/db directory.
In this case all you need to do is backup any data you need and remove the associated volume.
If using vs code with the docker extension, you can simply open your docker tab in the sidebar, expand the volumes section, locate the volume in question (for me it was called mongo-4-2-upgrade-test_mongo-data which depends on how your various containers are named for your project), right-click and remove.
Ensure that the containers that use this volume have been properly shut down or you'll get a 409 conflict error. I did the same as above but found my mongo container (in the containers section of the docker tab) instead. then when I restarted my docker-compose file the new version of mongo was installed and ran as expected.
I first ran brew install mongodb, which successfully completed and installed version 3.4.4. I was then able to start the server using brew services start mongodb, and access the shell via running mongo.
Then I discovered I need mongodb version 3.2.0. I uninstalled mongo v3.4.4 via brew uninstall mongodb and verified service was gone and bin files removed.
I then ran brew search mongodb and found mongodb#3.2 in the list, and so ran brew install mongodb#3.2. This completed successfully, and I was able to start the server using brew services start mongodb#3.2, which is successful. I then go to access the shell via 'mongo', or 'mongo#3.2' or 'mongo32' and none of these exist.
What should this bin file be named and why can't I find it? with v3.4.4 shell bin executable was /usr/local/bin/mongo - this file doesn't exist after installing 'mongodb#3.2'.
I see it in /usr/local/Cellar/mongodb#3.2/3.2.11/bin/ along with all the other binaries.
I don't know why it isn't symlinked to /usr/local/bin/ like most other programs.
As mentioned above, I need to install only the mongo shell on a RHEL instance (machine A).
I have a mongodb server on a separate instance (machine B) and need to connect to that from A to run mongodump and mongorestore commands.
I tried looking it up on the web but all I got was instructions to install the complete mongodb package.
Any help appreciated.
Official documentation says that you should be fine installing mongodb-org-shell only.
Create a repository file at sudo vim /etc/yum.repos.d/mongodb.repo
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
gpgcheck=1
enabled=1
sudo yum clean all
sudo yum install mongodb-org-shell-4.0.2
mongo <mongo-server-ip> Note: Step 4 will not work in all cases. You need to check proper command to connect to remote mongo server.
Source: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
You can follow the official tutorial on installing mongodb, and instead of installing the main package that will install all the packages, just install the package containing mongoshell
Please follow below steps.
Create a file /etc/yum.repos.d/mongodb.repo
Update the above file to contain:
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
sudo yum install -y mongodb-org-shell-2.6.9
mongo mongo-db_server_IP:27017/database_name -u username -p password
You might want to install mongosh (MongoDB Shell) instead. The legacy mongo shell has been deprecated since MongoDB v5.0 and replaced by mongosh. From the mongosh docs:
The new MongoDB Shell, mongosh, offers numerous advantages over the
legacy mongo shell, such as:
Improved syntax highlighting.
Improved command history.
Improved logging.
Currently mongosh supports a subset of the mongo shell
methods. Achieving feature parity between mongosh and the mongo shell
is an ongoing effort.
To maintain backwards compatibility, the methods that mongosh supports
use the same syntax as the corresponding methods in the mongo shell.
To see the complete list of methods supported by mongosh, see MongoDB
Shell Methods.
Further reference: Compatibility Changes with Legacy mongo Shell
Head to Mongo download page; download your required package regarding your operating system. Finally follow the instruction of your operating system to install the package.
Especially to install mongo or mongosh:
download .tgz file and untar the file into /usr/local/
add /usr/local/mongo/ into the shell profile (e.g. ~/.bashrc) and restart your terminal
For more information read the docs.
P.S.: mongo in the path should be vary based on the version of the downloaded package.
I'm very new to MongoDB and Mac in general. I installed mongoDB from the official site with a download package.
For all it's worth, given all the issues I'm having, I'd like to uninstall it and reinstall using Homebrew. Brew complains that mongoDB is already installed so I'm stuck at the moment.
From all the tutorials and online search, the config file should be installed in a /etc/ directory path. However, my mongodb.conf file is located in a very different file structure. I get a ERROR: could not read from config file each time I try running mongod.
This is where my config file is located:
/opt/sm/sets/versions/databases/head/mongodb/templates/mongodb.conf
How do I either :
Get the current version working (MongoDB shell version: 2.4.6)
Uninstall mongoDB entirely so I can install it with Homebrew (which seems a lot more straight forward)?
EDIT: I've also tried following this guide with no luck. http://www.mkyong.com/mongodb/how-to-install-mongodb-on-mac-os-x/
Thanks
Issue resolved with following steps (thanks to Karl Seguin's 'The Little MongoDB Book').
If you installed MongoDB via the download package from mongodb.org, you have to create create your own config file in /bin. Follow the instructions below
(copied from Karl Seguin's book):
download package
unzip package
Create a new text file in the bin subfolder named mongodb.config (if you have permission issues saving the file, save it first to your desktop then move file into folder).
Add a single line to your mongodb.config: dbpath=PATH_TO_WHERE_YOU_WANT_TO_STORE_YOUR_DATABASE_FILES.
For example, on Windows you might do dbpath=c:\mongodb\data and on Linux you might do dbpath=/var/lib/
mongodb/data.
Make sure the dbpath you specified exists
Launch mongod with the --config /path/to/your/mongodb.config parameter
For me, my launch path to the mongodb.config file was:
mongod --config /opt/sm/sets/versions/databases/head/mongodb/bin
(Note, this is to mongodb.config, not mongodb.conf file as many tutorials ask to point to.)
Hope this helps someone.
Link to Seguin's book(it's free): http://openmymind.net/mongodb.pdf
In windows if you want to run mongodb with config don't forget quotes to indicate location of mongo.config.
Example: if your mongod.exe is located in C:\Program Files\MongoDB\bin and you are located in that folder with prompt(with admin privileges) and supposing that mongo.config is in C:\Program Files\MongoDB run:
mongod.exe --config "C:\Program Files\MongoDB\mongo.config"
the extension of your config file does not matter but if you don't get it right it might not read from it.
if you used a text editor like notepad make sure the file extension is exactly the same.
else add .txt to the end /opt/sm/sets/versions/databases/head/mongodb/templates/mongodb.conf.txt
you must of have thought you saved it with a mongodb.conf while it was actually mongodb.conf.txt