I installed mongodb in my mac and following is the way I installed. Where is my mongodb log file located?
$ tar xzf mongodb-osx-x86_64-2.2.3.tgz
$ sudo mv mongodb-osx-x86_64-2.2.3 /usr/local/mongodb
$ sudo mkdir -p /data/db
$ sudo chown 'whoami' /data/db
$ vim .bash_profile
export MONGO_PATH=/usr/local/mongodb
export PATH=$PATH:$MONGO_PATH/bin
Where is the settings file of mongodb located which stores all this information.
I installed mongo with brew, and it was located at /usr/local/var/log/mongodb/mongo.log
I found it by running
find / -name mongo.log
From the mongo shell you can find the path for data, log and config using:
db.serverCmdLineOpts()
As #dcrosta answered here: Sane defaults for MongoDB on OSX, MongoDB only have default values for the data path. All other locations shall be established by the user if desired.
In the installation process you posted here, can't see any command to set the log path so, in conclusion, your MongoDB is not saving any log file.
With the default mongodb-community homebrew installation on a Macbook Pro with Apple Silicon, the logs are with the rest of the homebrew services logs, at /opt/homebrew/var/log. I think the location is different with Intel silicon, but the concept should be the same.
Related
I download the latest version of the Fly cli
https://concourse-ci.org/download.html
to ~/Downloads then cd to ~/Downloads
cd ~/Downloads
mv fly_darwin_amd64 fly
install fly
then I do
fly
and i get
-bash: fly: command not found
Is one of my steps wrong?
Try
cd ~/Downloads
mv fly_darwin_amd64 /usr/local/bin/fly
chmod 0700 /usr/local/bin/fly (Thanks to #Andrew Ramnikov)
For the newest mac os version, you need to allow the App to run from System Settings->Security and Privacy->General-> Allow app
fly -version
On MacOS, you can install with brew like, brew install --cask fly.
You might also want to install CredHub to manage credentials, brew install cloudfoundry/tap/credhub-cli.
Note that in the accepted answer, in Catalina and Newer the equivalent to the last step to allow the app in privacy settings is: xattr -d com.apple.quarantine /usr/local/bin/fly
And this does not require admin rights, but doing it via the GUI does.
Go to System Preferences -> Security & Privacy -> General and click allow anyway next the the fly app.
I ended up moving the fly binary to a folder in my home directory, and just added it to my path variable in ~/.bash_profile so I guess it works now.
edit
However, when I do
fly -t main login
I get
error: unknown target: main
easiest way is to run first command curl 'http://localhost:8080/api/v1/cli?arch=amd64&platform=darwin' -o fly \ && chmod +x ./fly which will create a fly binary and for the second part of command just do it manually && mv ./fly /usr/local/bin/ meaning you need to copy fly binary into /usr/local/bin
I'm trying to setup a cronjob for a regularly scheduled import of json data into a mongo database. To conduct the import, I have the following command in the Python script that the cronjob runs:
os.system("mongoimport --jsonArray --db %s --collection %s --file .../data.txt" %(db_name,collection_name))
However, the log file of the cronjob keeps displaying the following error:
sh: mongoimport: command not found
I think I need to call mongoimport with the full file path in the code, but I'm not sure where mongodb/mongod/mongoimport is installed on my system. whereis mongoimport, whereis mongodb, whereis mongod all return nothing.
I installed mongodb with Homebrew. Packages installed with Homebrew are located in /Library/Caches/Homebrew. However, in my system that folder only has a mongodb-2.6.4_1 tar file. Do I have to unpack this tar file to access mongoimport?
Thanks for your help.
As of June 2020,
I installed mongodb latest version using brew as per the documentation , and I faced the same issue command not found: mongoimport .
I had to to install mongodb-database-tools
brew install mongodb/brew/mongodb-database-tools
Then I could use mongoimport
Just adding this solution, incase it helps someone
Got the same issue, but I installed mongodb via Mac Port. Unfortunately, from version 3 of mongodb, these mongodb tools are maintained as a separate project, so I updated Mac port to latest version then installed mongo tools separately.
sudo port install mongo-tools
Hope this helps someone that installing mongodb by mac port.
If you installed MongoDB correctly you need to create a ~/.bash_profile and assign /usr/local/mongodb/bin to the $PATH environment variable
After that you should be able to access the mongoimport command
If you used brew for installation, mongod is in /usr/local/bin/ directory. Other utilities (mongoimport, mongoexport etc.) are in the same path. All you need to do is open another terminal.
Visit https://www.mongodb.com/download-center/community and you can download a tarball for MacOS, which contains all the tools including mongoimport.
Untar, add to you PATH and voilà !
Try using ./mongoimport or sudo ./mongoimport
After following all of these examples, I was able to use it that way from bash.
I am trying to test MongoDB and I have it all downloaded and moved into the root folder. I can navigate to the folder that holds the mongod, but when I try to run it by typing "mongod" into my terminal, I get a message that says:
"mongod: command not found"
Both answers above are correct.
You can either specify the path in one of the following files: .profile, .bashrc, or .bash_profile
export PATH="$PATH:/usr/local/mongodb/bin"
then call the daemon or the shell directly
mongod
mongo
Or for the commands not in the $PATH, use ./mongo or ./mongod from the directory containing these files. This solution can be verbose has you will have to eventually append the whole path when calling these commands from another directory.
/usr/local/mongodb/bin/mongod
or
/usr/local/mongodb/bin$ ./mongod
"Mongod" isn't a stand-alone command. You need to run the command like this:
./mongodb/bin/mongod
I used this webpage to help me answer this question.
This worked for me:
brew tap mongodb/brew
brew install mongodb-community#4.2
mongod
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/
For example, install 64bit MongoDB 2.6.12 on macOS Catalina.
(for newest versions you may go to https://www.mongodb.com/download-center/community for your platform).
Download, extract and move:
wget http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.6.12.tgz
tar xzf mongodb-osx-x86_64-2.6.12.tgz
mv mongodb-osx-x86_64-2.6.12/ /usr/local/mongodb/
Add to file ~/.zshrc this:
export PATH="$PATH:/usr/local/mongodb/bin"
PS: .bash_profile or .profile not worked in my case
Reload terminal (or close, open it):
source ~/.zshrc
Make directory for data and set rights:
mkdir -p ~/data/db
chown -R mongodb.mongodb ~/data/db
Run MongoDB:
mongod --dbpath ~/data/db
You need to add the name of the folder that contains the command mongod into your PATH so your shell knows where to find it.
So, if mongod is in /usr/bin/freddyfrog, you would edit ~/.profile and find the line that says PATH= and edit it to look like this:
export PATH=${PATH}:/usr/bin/freddyfrog
Then login again to make it take effect.
I received the same error message because I used the wrong command to run mongod (meant for M1s) for my 2019 MacBook with an Intel processor. You can skip past Homebrew updates and MongoDB installation but here's how I resolved my issue:
Download Xcode Command Line tools.
xcode-select --install
Allow Homebrew to add and access MongoDB:
brew tap mongodb/brew
Update Homebrew:
brew update
Install MongoDB Community Edition (#6.0 is the latest version at the time of this post):
brew install mongodb-community#6.0
macOS with Intel processors:
mongod --config /usr/local/etc/mongod.conf --fork
macOS with Apple M1 processors:
mongod --config /opt/homebrew/etc/mongod.conf --fork
Then open the shell:
mongosh
Or just run mongod.
Official documentation on installation here.
3 steps:
Step 1:
export PATH="$PATH:/usr/local/mongodb/bin"
OR
export PATH="$PATH:/usr/local/opt/mongodb#3.2/bin"
(replace version number with your local version)
The first step will allow you to run the command, but will get you another error: "/data/db does not exit" so you have to
Step 2 :
sudo mkdir -p /data/db
Now /data/db is read only, but it has to be writable also so
Step 3 :
sudo chown -R USERNAME /data/db
I was trying to install a previous version (3.6) using latest documentation (4.2 is already released). So, they now call it mongodb-community#3.6.
In order to update PATH for such setup, the statement should be
export PATH="$PATH:/usr/local/opt/mongodb-community#3.6/bin";
I got hint from #retroGiant 's answer
run this command, it works:
brew services start mongodb-community#4.0
I have installed mongodb-community#3.2, was facing the same issue. I followed below steps.
open bash profile in any editor (you can also try - vi ~/.bash_profile)
write this export PATH="$PATH:/usr/local/opt/mongodb-community#3.2/bin" & save.
do this . source ~/.bash_profile
In root directory
sudo mkdir data
cd data
mkdir db
then
sudo chown -R yourUsername /data/
copy path of your mongodb/bin downloaded folder (I suggest you put it in home folder not root dir)
in terminal
export PATH="paste the link here :$PATH"
now it should work but if not
In case you are using different Unix shell and
trying to execute mongod within visual studio code( for example ),
make sure to read the documentation to link PATH.
For example, if you are using zsh create .zprofile in your home directory.
touch .zprofile
copy your previously made PATH into .zprofile
Now everything should work as expected.
I was looking for the same and later I have found that now it's very straight forward to install the new MongoDB Community Edition like below:
Installing MongoDB 6.0 Community Edition
brew tap mongodb/brew
Note: If you haven't yet install brew then follow this link: https://brew.sh/#install
Update Homebrew
brew update
Install MongoDB
brew install mongodb-community#6.0
The installation includes the following binaries:
The mongod server
The mongos sharded cluster query router
The MongoDB Shell, mongosh
Run MongoDB Community Edition
To run MongoDB (i.e. the mongod process) as a macOS service, run:
brew services start mongodb-community#6.0
To stop a mongod running as a macOS service, use the following command as needed:
brew services stop mongodb-community#6.0
MongoDB 5.0 issue resolved - SEP/2022
do following steps
step 1: open a .zshrc file if it does not exist it will create by itself by following the command. For opening or creating a .zshrc file below command is the same.
vim .zshrc
step 2: insert value in it by pressing 'i'
step 3: insert the below command there or paste it there.
export PATH="$PATH:/usr/local/opt/mongodb-community#5.0/bin"
step 4: to exit click on esc key and the write :wq
step 5: Close the terminal and reopen it and type the below command
mongo
Output
MongoDB shell version v5.0.11
connecting to: mongodb://127.0.0.1:279021/?
compressors=disabled&gssapiServiceName=mongodb
Successfully integrated mongo 🎉 🎉 🎉
happy coding !!
If you use brew then check the path:
brew list
brew list mongodb-community#...
then add it to .zshrc
zsh: command not found: mongo
after that use mongosh instead of mongo
This answer is a little bit unrelated, but if you using vscode & would like to interact with mongoDB using command line, have a read.
I was looking to use mongod command as well (as i love to use command to interact with mongoDB), but after several attempts of install i completely give up. Until i found this, the mongoDB vscode extension.
The extension is loading the data pretty fast just like mongod command compare to mongo compass. It allow you to perform CRUD & aggregation in the mongoDB playground, and most importantly you able to retrieve the command on next execution by storing your command in a file with .mongodb extension.
*Update: After using it several weeks, everything is nice, just need to make sure you connecting to the right mongoDB connection (if you establish few different connection)
I've installed Postgres93 on my Mac. I can open the application, and "Open psql" through the app which opens up a command line interface with psql.
However, when I type $ which psql nothing is returned. The installation path is /Applications/Postgres93.app. How do I make $ which psql show the correct result?
Mac OS X - Mavericks
PostgreSQL package, I'm not as sure about. I went here and downloaded it - http://postgresapp.com/
I just had postgres installed and was not able to run the psql command until I ran the following command in my terminal:
export PATH="/Applications/Postgres.app/Contents/Versions/9.5/bin:$PATH"
Now the terminal knows where to find postgres when I use the psql command.
Remember to replace the version number '9.5' with your current version.
I had the same problem with nothing showing for the which psql command till I run the command below to resolve it. The command provided below is just a little tweak of what has already been provided by others here. The only difference is, instead of providing a specific postgres version number in the command, you can simply tell postgres to use the latest postgres version by simply running the following command:
export
PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
And now my terminal was able to find the path to postgres when I run which psql.
Hope this helps.
On macOS Mojave these instructions work well:
If your Postgres has not been installed yet, I suggest you use the great "brew" package manager from here https://brew.sh/ :
$ brew cask install postgres
or you can install it usual way from the website
Put this to the bottom of your ~/.bash_profile file:
export PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:${PATH}"
Restart your terminal or restart your ~/.bash_profile directly with the command:
$ . ~/.bash_profile
Verify your installation:
$ psql --version
** Edited: to include a permanent fix, not just during your current session. **
I had this same problem, and also found a clear answer lacking in the docs.
To fix:
Download the new app, and follow the instructions to move it to the Applications folder
Add the new bundle to your path by typing the following in your Terminal (version number specific - mine is 9.4):
PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"
To fix the issue on a permanent basis, run the same line but with export in front:
export PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"
It appears that you installed Heroku's Postgres.app, which is a tool intended for throw-away testing and development. Add the contents of the bundle to your PATH by following the instructions in the Postgres.app documentation - see "command line tools".
On macos mojave i've added the following line on my ~/.profile :
export PATH=$PATH:/Library/PostgreSQL/10/bin
the psql command line client lies into this folder. i've used the enterprisedb installer.
I just experienced the same problem, and solved it by adding export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin to .bash_profile. Note that this line is version-specific, so be sure to check this line against your current version of Postgres.app.
Using Mac OS Monterey, the latest Homebrew (3.4.0) and postgres#13.
I was able to add psql to the path by using -
export PATH="/opt/homebrew/Cellar/postgresql#13/13.6/bin:$PATH"
Replace #13 and 13.6 with your version.
The latest homebrew install location seems to be /opt/homebrew/*
I'm using catalina 10.15.3 and I had the same issue after installing psql using homebrew. Then I noticed, homebrew mentioned
==> libpq
libpq is keg-only, which means it was not symlinked into /usr/local,
because conflicts with postgres formula.
If you need to have libpq first in your PATH run:
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.bash_profile
So, I ran 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.bash_profile and psql was added to my path
In Mac, there is a SQL Shell application already under /Applications/PostgresSQL
try that
Also, you can run /Library/PostgreSQL/11/scripts/runpsql.sh
In my case, I installed Postgres12 and had the same issue. I had to look out for the location of my bin folder. It happened to be in /Applications/2ndQuadrant/PostgreSQL/12/bin. So I had to run export PATH="/Applications/2ndQuadrant/PostgreSQL/12/bin:$PATH" in my terminal and restart the terminal. That solved it.
I'm working on the front end for a web app, but I'm trying to learn as much of the backend setup as I can as well. I am setting up redis on a new computer myself, but running into a few hiccups.
The wget command cannot be found, so I assume it Linux only? I am following these instructions to install redis on Mac OS 10.7. I have redis 2.0.0 installed, but while attempting to install 2.4.4 using the same commands, I am told redis-server, redis-cli, redis-benchmark cannot be found, and I can't copy them to /usr/local/bin.
I could not find an update command to bring redis up to the most recent version. I don't think it should be this difficult to install the most recent version on redis on Mac OS, but I can't see what I am doing wrong.
So far as I know, typing:
$ brew upgrade redis
should work, where $ indicates your command line. If it complains about HomeBrew not being installed, you can obtain that here. Brew is an excellent package manager, and a great way of taking care of your files.
If you're not using brew, then these steps will help you get up to date.
First, find the location of your installed redis-server instance before updating. In my case, it was in /usr/local/bin/, but it might also be in /usr/bin/. If it's not here, you can type which redis-server to find the location.
Next, download the redis tar file from https://redis.io/download, then install it from the directory it downloaded to:
cd Downloads
tar xzf redis-X.Y.Z.tar.gz
cd redis-X.Y.Z
make test
make
Next, we'll move the new installed redis to the location where the current instance is running:
sudo mv src/redis-server /usr/local/bin
sudo mv src/redis-cli /usr/local/bin
Now you should be ready to use redis-server and redis-cli in the new version.
PS - I also moved the redis-benchmark, redis-sentinel, redis-check-aof, and redis-check-dump files because they were also already in /usr/local/bin.
Ref: http://jasdeep.ca/2012/05/installing-redis-on-mac-os-x/
It would be better to follow this way.
$ brew update
$brew upgrade redis
Create a bash file...
cd ~
nano .update_redis
Go into the tmp directory and download the latest stable version
cd /tmp
wget http://download.redis.io/redis-stable.tar.gz
Decompress the files
tar xvzf redis-stable.tar.gz
Compile
cd redis-stable
make
Copy the bin programs
cp src/redis-cli /usr/bin/
cp src/redis-server /usr/bin/
cp src/redis-benchmark /usr/bin/
Set Permissions
chmod 755 /usr/bin/redis-cli
chmod 755 /usr/bin/redis-server
chmod 755 /usr/bin/redis-benchmark
Execute
bash .update_redis