Command not found: psql - macos

After following the installation guide here: https://postgresapp.com/, I ran the command in step 3 to configure my path and was presented with this:
/Applications/Postgres.app/Contents/Versions/latest/bin
However, after then typing which psql I get psql not found, and when trying to start my local database get command not found: psql.
I am able to start up the PostgreSQL app and initialize, but can't seem to run any commands in the terminal associated with psql.

Related

Running Oracle NETCA/NETGMGR/DBCA on Docker for Windows

I am trying to run dbca/netca commands on docker.
I already have Oracle 12c installed on docker, but I keep running into a issue.
When I run the dbca command, I get the error:
DBCA cannot be run as root.
When I run the netca command, I get the error:
Oracle Net Configuration Assistant cannot be run as root.
When I run the netmgr command, I get the error:
Could not find the main class: oracle.net.mgr.container.NetApplication. Program will exit.
-netca/netmgr/dbca are all GUI tools managed by Oracle.
When I sudo su - oracle user, and I run the above commands, the docker/ system no longer even recognizes those commands.
See below:
oracle#6cc1eee63141:~$ dbca
-su: dbca: command not found
oracle#6cc1eee63141:~$ netca
-su: netca: command not found
oracle#6cc1eee63141:~$ netmgr
-su: netmgr: command not found
oracle#6cc1eee63141:~$ NETMGR
I have already exported my display to my computer IP address.
What am I doing wrong and how can I fix it?

Can't Run psql From Command Line After Adding To Path

I had Postgres installed on OSX. Postgres.app 9.5. I wanted PGAdmin so I uninstalled it thinking that was the way. I realized I needed the dependencies and pgadmin will just allow me a GUI to work with them. So After I had pgadmin installed I installed Postgres.app again. I added the bin path to pgadmin preferences.
At this point when I start the shell from the postgres.app I \list my Db and I can see the ones I have made.
Then I run pgadmin and I can see the same databases inside the GUI.
But I cant run psql from the command line.
Not in terminal
Not in iTerm
When I paste this into the terminal I can start an active shell,
'/Applications/Postgres.app/Contents/Versions/9.6/bin'/psql -p5432 -U postgres
But when I type this in terminal or iterm I get permission denied,
/Applications/Postgres.app/Contents/Versions/9.6/bin psql
zsh: permission denied: /Applications/Postgres.app/Contents/Versions/9.6/bin psql
When I run with sudo I get command not found.
I added this to my ~/.bash_profile
export PATH="/Applications/Postgres.app/Contents/Versions/9.6/bin:$PATH"
Then I ran,
source ~/.bashrc
I also quit out of terminal and iterm but when I run psql I still get command not found.
Any help from here would be great. I want to add psql to my path so I can do things like,
psql --Version
etc.

-bash: initdb: command not found

I have installed PostgreSQL using the EnterpriseDB installation.
I ran sudo ./postgresql-9.3.5-3-osx.app/Contents/MacOS/installbuilder.sh --mode unattended and then ran open /Applications/TextEdit.app .profile to edit my .profile file newly created in /Users/Dhruv to add the line source /Library/PostgreSQL/9.3/pg_env.sh.
Running createuser Dhruv --pwprompt --username=postgres I got
-bash: createuser: command not found
Then running unknown-88-1f-a1-1b-c2-ec:9.3 dhruv$ sudo -u postgres /bin/createuser and various other methods I was able to set up something using some sort of password prompt. I know this later because using sudo -u postgres /Library/PostgreSQL/9.3/bin/createuser I got
createuser: creation of new role failed: ERROR: role "postgres" already exists
Running then initdb -D /Library/PostgreSQL/9.3/data I get
-bash: initdb: command not found.
Similiarly, if I try the same thing but while connected to postgres, sudo su - postgres and then initdb -D /Library/PostgreSQL/9.3/data I get again
-bash: initdb: command not found.
At a loss at what to do. 1) how do I know details of this supposed role "postgres" I created magically and 2) why is initdb not working?
How I fixed this is run brew doctor, and you might see the postgresql un der the Warning: that indicates there's unlinked kegs in your Cellar.
Try to run brew link postgresql. It will show some symlinks got created. Then run init db ... again.
Hope this help!
Who are you logged in as?
When you do sudo or su -, it will run init scripts for root, such as .bashrc and .bash_profile.
These may set up difference executable search paths between root, postgres, and you.
Try something like sudo initdb, or su - postgres -c initdb ... whichever user has the paths constructed correctly, so that the path gets set up.
You could also duplicate the path/lib creation code in your own environment, but that will break if it is ever changed.
Same thing happened to me. I'm new to OS X coming from Linux, here's what I had to do. I installed postgres via homebrew and when I did so I noticed it put everything it download to: /usr/local/Cellar/postgresql/($postgres_version)/
When I cd'd into that folder I saw a directory named bin so I cd'd and saw initdb right there. So I had to then add this to my path so I could use the command:
$ export PATH=/usr/local/Cellar/postgresql/9.4.4/bin:$PATH
hope that helps you

How to configure PostgreSQL server on MacOS 10.8.5?

I'm trying to connect to my postgres server from command line :
$> psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
And I'm trying to run the server :
$>postgres
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the
PGDATA environment variable.
Can anyone point out for me how can I configure my server so it works?
I've solved this problem. Actually Mac OS 10.8.5 has his own psql command. So it's a path issue. If you install postgres from MacPort, the system will always refer to the initial psql command.
I advice you to install postgres from brew as shown here.
You'll have also redefine your PATH environment variable and export it in your .profile file:
export PATH=/usr/local/bin:$PATH

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