Unable to set "mongod" PATH - macos

I'm having issues trying to run mongod upon terminal start up.
OS
OSX 10.11.4
Steps so far:
Download OS X 10.7+ 64-bit
Uncompress mongodb-osx-x86_64-3.2.5.tgz
Rename mongodb-osx-x86_64-3.2.5 to mongodb
Moved /mongodb to [Desktop/development]
Add /data/db to Desktop/development/mongodb/bin
Changed permissions to /data/db using chmod 777 /data/db
Within Desktop/development/mongod/bin typing ./mongod everything is working as expected and I can access the the mongo shell. Now I would like to just be able to type mongod upon terminal startup and run both mongo and mongod
PATH for mongod
Open bash file vi ~/.bashrc
While in insert mode: export PATH=Desktop/development/mongodb/bin:$PATH I've also tried export PATH=$Home/Desktop/development/mongodb/bin:$PATH
What am I missing or doing wrong?
Thanks
EDIT
As per suggestions I've moved all the mongo files into a more appropriate locations.
Mongo location: $HOME/mongodb/bin
Mongo DB location: $HOME/mongoData
Data/db location: $HOME/mongoData/data/db
Bash command: export PATH=$HOME/mongodb/bin:$PATH
I'm thinking this is correct, but still unable to run mongod is there something missing in the bash command? Like mongo = PATH=...?

Desktop is actually $HOME/Desktop as it's in your home directory, so you need:
export PATH=$HOME/Desktop/development/mongodb/bin:$PATH
Desktop is not the place to put stuff as it's nothing much more than a convenience area that you can add to and remove from at a whim. It's also too visible as you will see the folder icons.
You should have installed all that stuff into your home directory (or /usr/local if you want it available to all users).
Also "Add /data/db to Desktop/development/mongodb/bin" doesn't look right to me as data and executables are different.
If I was adding mongodb for development then I would have installed it via Macports with:
$ sudo port install mongodb
and would be up and working in less than 2 minutes.

Related

Installing Glassfish, Wildfly using homebrew on Mac OSX

Trying to install Glassfish(Java EE App. Server) and Wildfly App Server using Homebrew .
http://macappstore.org/wildfly-as/
http://macappstore.org/glassfish/
used these above mentioned tutorials .
I got the following errors while trying to run them by typing just "glassfish" & "wildfly-as" respectively.
Output(Error):
-bash: glassfish: command not found
-bash: wildfly-as: command not found
Searched about it and I think it has something to do with $PATH. I don't understand $PATH Variable . Need help.
The issue is that there are two asadmin scripts. One at $GLASSFISH_HOME/bin and one at $GLASSFISH_HOME/glassfish/bin
Here are full instructions to get your domain up
brew update
brew install glassfish
you should see message, add that line to your .bash_profile
==> Caveats
You may want to add the following to your .bash_profile:
export GLASSFISH_HOME=/usr/local/opt/glassfish/libexec
Open a new terminal then, cd $GLASSFISH_HOME/glassfish/bin
./asadmin start-domain --verbose
Browse to http://localhost:8080 for welcome page and http://localhost:4848 for admin console
I actually installed Wildfly-Application Server using homebrew but could not find a way to run it.
https://tomylab.wordpress.com/2016/07/03/how-to-install-wildfly-on-mac/
This tutorial helped me .
And for glassfish, my installation was again successful using homebrew but was not able to run it . I did figure it out when I ran the following commands.
$ cd /usr/local/opt/glassfish/libexec/bin
$ ./asadmin
asadmin> start-domain
You need to understand about the PATH variable. It is an environment variable on Unix-like operating systems, specifying a set of directories in which executable programs are located. In general, each executing process, or user session, has its own PATH setting.
So, you need to add the glassfish home path to your actual path variable.
Now, as per your problem with running the Glassfish server; try this:
export GLASSFISH_HOME=/usr/local/opt/glassfish/libexec/
export PATH=$PATH:$GLASSFISH_HOME/bin
Add it to your bash profile, if you do not want to do this everytime.

How do I ensure that Mongo binaries are in my PATH - in my shell' rc (~/.bashrc) on a Mac

I am learning mongoDb.
I did the following: I understand this.
mkdir -p mongodb
cp -R -n mongodb-osx-x86_64-2.6.7/ mongodb
These next ** instructions are not crystal clear to me.
**
Ensure the location of the binaries is in the PATH variable.
The MongoDB binaries are in the bin/ directory of the archive. To ensure that the binaries are in your PATH, you can modify your PATH.
For example, you can add the following line to your shell’s rc file (e.g. ~/.bashrc):
export PATH=<mongodb-install-directory>/bin:$PATH
Replace with the path to the extracted MongoDB archive.
End of the instructions.
From terminal on my Mac
$which bash
/bin/bash
The bin directory has a bunch of commands: bash, chmod, ln, pid, mkdir.
I cannot find the directory where I should include the PATH code above.
Thanks
Abhay's instructions worked !
Sorry that the following is long but I believe it is necessary because you were so clear last time and I want you to see my file structure.
If email is easier let me know but this will more likely than not help others :)
I really want to understand my file structure so if you do not mind a bit of further clarification.
Thanks again for your expertise.
1.
But why are all of the binaries (the executables) listed individually in this bin folder ? Are they the 'only' files that should 'live' in this folder ?
Perhaps when I was installing bower grunt etc. I should installed those (bower grunt etc) into a different location.
I am trying to keep my file structures logical and clean.
Here is what I have.
MacBookPro:usr regina$ cd ..
MacBookPro:/ regina$ ls
Applications bin net
CoreSyncInstall.log cores private
Library data sbin
Network dev tmp
System etc usr
Users home var
Volumes mach_kernel
MacBookPro:/ regina$ cd usr/local/bin
MacBookPro:bin regina$ ls
bower grunt mongod mongorestore npm
browserify gulp mongodump mongos statsd
bsondump http-server mongoexport mongosniff yo
cake karma mongofiles mongostat
coffee lessc mongoimport mongotop
cordova mkdirp mongooplog node
express mongo mongoperf nodemon
MacBookPro:bin regina$
2.
Also, I wanted to look at my .bashrc file. I do not have one. I am on osx 10.8.5 I want to 'view' my $PATH variable. I believe I found it somewhere months ago. I was using nano to open a bunch of files because I was curious. Was it listed as an environmental variable ?
MacBookPro:/ regina$ ls
Applications bin net
CoreSyncInstall.log cores private
Library data sbin
Network dev tmp
System etc usr
Users home var
Volumes mach_kernel
MacBookPro:/ regina$ cd home
MacBookPro:home regina$ ls -la
total 2
dr-xr-xr-x 2 root wheel 1 Feb 3 08:29 .
drwxr-xr-x 33 root wheel 1190 Jan 25 17:21 ..
MacBookPro:home regina$
I start the mongo shell like this. I am not showing all of the lines output in terminal.
Look at my file structure. I originally followed a cp command but it did not explain 'where' to copy the archived (desktop) mongodb-osx-x84.... folder so look where I copied it to. Now I have these files in 2 locations - yes ?
And I have a mongodb folder inside of a higher level mongodb folder.
Why ? How did I manage this ? It seems illogical. I have been indented 4 spaces but the below will not format so I just added line breaks. sorry.
MacBookPro:home regina$ cd ..
MacBookPro:/ regina$ ls
Applications bin net
CoreSyncInstall.log cores private
Library data sbin
Network dev tmp
System etc usr
Users home var
Volumes mach_kernel
MacBookPro:/ regina$ cd data
MacBookPro:data regina$ ls
db mongodb
MacBookPro:data regina$ cd mongodb
MacBookPro:mongodb regina$ ls
mongodb
MacBookPro:mongodb regina$ cd mongodb
MacBookPro:mongodb regina$ ls
GNU-AGPL-3.0 THIRD-PARTY-NOTICES
README bin
MacBookPro:mongodb regina$ cd bin
MacBookPro:bin regina$ ls
bsondump mongodump mongoimport mongorestore mongostat
mongo mongoexport mongooplog mongos mongotop
mongod mongofiles mongoperf mongosniff
This is what happens when I try and type 'mongo' as another forum suggested.
MacBookPro:bin regina$ mongo
MongoDB shell version: 2.6.7
connecting to: test
2015-02-03T08:36:54.157-0500 warning: Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
So I typed this which still failed.
MacBookPro:bin regina$ ./mongo
MongoDB shell version: 2.6.7
connecting to: test
2015-02-03T08:37:03.599-0500 warning: Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
Then I tried this which connected - opened port 27017 - and is listening. Why did I need the daemon command ?
MacBookPro:bin regina$ ./mongod
./mongod --help for help and startup options
2015-02-03T08:37:08.712-0500 [initandlisten] MongoDB starting : pid=487 port=27017 dbpath=/data/db 64-bit host=macbookpro.home
more lines of code
2015-02-03T08:37:09.018-0500 [initandlisten] waiting for connections on port 27017
When you download MongoDB for Mac, you get an archive file. First thing you need to is uncompress the archive. To do that you just double click on the archive. The uncompressed folder will have the binaries in the bin folder, like mongodb-osx-x86_64-2.6.7/bin. What you need to do next is to make sure these binaries are accessible. So, for this you can do either of the two things -
Copy the binaries to /usr/local/bin folder. As /usr/local/bin is always in PATH, so you don't have to add it to the PATH.
This is pretty simple. Run cp mongodb-osx-x86_64-2.6.7/bin/* /usr/local/bin/. That's it. You are all done.
Add the binary folder's path to your $PATH variable.
Open the .bashrc file, which is located in your home folder, and put export PATH=$HOME/mongodb/bin:$PATH line in the end. I am assuming that mongodb uncompressed in downloads.
If going by the second method, make sure you don't accidently delete the mongodb folder that is added in the PATH.
Once you have finished doing this, close the terminal, open a new terminal window and run:
mongo --version
If you get the mongodb info with version, then good.
If you still get something like command mongo not found, then make sure you followed above instructions right. Also make sure you are not using any other shell, like zsh. If you are, then you have to add the export statement in the respective shell file. For zsh the file name is .zshrc.
Okay! So as you have updated the initial question with some more questions. So here goes the explanation point by point:
The files you see in /usr/local/bin folder are binaries. In simple language, they are executable programs. These executable binaries live there though you can run them from anywhere in the command line.
The .bashrc file is found in user's home directory. On Mac it's /Users/username. In your case, it should be /Users/regina because your name is Regina.
mongo is the client application. It is used to interact with the mongodb database. And, mongod is the database deamon that stores the data. So first you have to run mongod, and then only you can connect to it using the client mongo and start querying.

Unable to map path to postresql after installation of Postgres 9.3 to mac

After installing Postgresql by dragging folder into my applications folder I am unable to get commands to work in the terminal and unable to add the path so that is shows up using the command $ echo $PATH.
Postgres starts in the terminal using the elephant icon on the system tray and selecting "open psql" so I believe it installed correctly.
I tried adding all different combinations of the following lines to my .bash_profile
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
then
PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH"
then
export PATH=$PATH:/Applications/Postgres93.app/Contents/MacOS/bin
and finally
export PATH=$PATH:/Applications/Postgres93.app/Contents/MacOS/bin
after each attempt I ran $ source $HOME/.bash_profile and then checked path and/or tried $psql $ which psql to no avail.
Also tried adding lines to .bashrc , .profile and .zshrc without luck.
The path to the executable commands bin folder in the app (psql, createdb, createlang, etc..) is
$ /Applications/Postgres93.app/Contents/MacOS/bin
Any help would be greatly appreciated!
running OSX 10.9.1
https://superuser.com/questions/707222/unable-to-get-postgresql-commands-to-work-in-terminal
answered at the link above by zelanix https://superuser.com/users/293259/zelanix

Meteor requires sudo to run

Previously I was able to start Meteor 0.6.6.3 by simply running mrt.
Recently, Meteor 0.7.0.1 wont run properly unless I run it as root with sudo mrt. Environmental variables like MONGO_URL requires root to set it.
Any ideas what happened? I'm using Mountain Lion on Mac OSX.
You might have run it with sudo once before. When you run it with sudo just once and a file is written the files become root files root user file so it needs more permissions to run and wont run
ordinarily.
You might have run sudo mrt once it must have updated files for a package but they're now owned by root instead of your normal user.
I'm sure theres a terminal command to get it back but using Disk Utility and running 'Repair Disk Permissions' can also fix it (i think).

connect failed mongo db on mac osx

i'm trying to learn mongo db on my mac. I installed mondgo db using homebrew and it appeard successful. I created the dir /data/db. when I type mongo into the terminal I get:
Error: couldn't connect to server [a bunch of numbers] at src/mongo/shell/mongo.js:145 exception:connect failed
I looked at the following answer on SO: Installing and Running MongoDB on OSX
in the check answer it says:
1) Start a terminal for your mongo server
2)Go to mongo/bin directory
What does it mean to start a terminal for your server? does that mean just open up a new terminal window?
Where can I find the mongo/bin directory?
Any other suggestions on getting mondoDB up and running would be appreciated.
you should read the documentation here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/
And follow the instructions.
In this case the [bunch of numbers] are the hostname/ip and port number that the binary mongo has tried to connect to. What it's telling you is that there is no mongod binary listening on the hostname and port that mongo is trying to connect to.
You will need to start mongod before you are able to connect to it with a mongo shell. The documentation above outlines this further.
If you use homebrew the mongodb binaries will automatically be put on your path which means you won't need to cd into another directory like mongo/bin.
Good luck.
Probably you run the mongodb first time. Based on the documentation you must follow a few steps and then you are ready to go.
First, create main db directory:
sudo mkdir -p /data/db
Make sure that you have a read and write permission on that directory:
sudo chown `id -u` /data/db
And to listen to default port, run:
mongod
Finally keep in mind that after the run "mongod" command do not close console tab. Open a new tab (Cmd + T) and run other commands on the new window. To close the mongod session simply hit the Ctrl + C on the previous tab.
when everything mentioned above did not work. I did the following thing (in Mac)
cd ~
mkdir -p data/db
After creating directory in home(which will be definitely allowed) most imp command is below
mongod --dbpath ~/data/db &
So that it could take the path of db which was in home directory (as we are not able to create in / dir.
To avoid it running frequently, put the above command in .bash_profile file in home directory so that it will automatically run the above command whenever we try to use terminal in Mac
Note: Whenever we open the terminal it will execute the above command so that we can access the mongodb (I understand this should be taken place in background but it works fine)
We need to press enter/return key to get the regular command line terminal and continue doing our work
These steps worked for me well on Mac, you can give a shot, make sure you install brew first and put these lines in terminal line by line:
brew update
brew install mongodb
brew install mongodb --with-openssl
brew install mongodb --devel
sudo mkdir -p /data/db
sudo chown -R [your username] /data/db
(Replace with your username with what you can get by typing whoami in the terminal)
mongod
Run you app, for example localhost:8000

Resources