In your command-line run the command: brew update
- In your command-line run the command:
brew install postgresql
- Read the Caveats section that is outputted to the Terminal.
- Run the command:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
- Open your zsh config file:
subl ~/.zshrc
- At the bottom of the file, create two new aliases to start and stop your postgres server. They could look something like this:
alias pg-start="launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist"
alias pg-stop="launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist"
Run the command: source ~/.zshrc
to reload your configuration.
from the man ln
command
The ln utility creates a new directory entry (linked file) which has the same modes as the original file. It is useful for maintaining multiple copies of a file in many places at once without using up storage for the
copies''; instead, a link
points'' to the original copy. There are two types of links; hard links and symbolic links. How a link ``points'' to a file is one of the differences between a hard and symbolic link.
from the man launchctl
command
launchctl interfaces with launchd to manage and inspect daemons, angents and XPC services.
Link: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04~
Ubuntu Installation Process:
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
Once that is complete run the command: psql
You will see an error. Read the error, what is it saying?
It says that the "...role [yourusername] doesn't exist" so we will create one with the needed permissions.
enter the command: $ sudo -u postgres -c 'psql'
this should log you into the postgres server.
To create a user, enter this command and replace yourusername
with your username from the error message previous: CREATE ROLE yourusername WITH LOGIN CREATEDB CREATEDB
enter: \q
to exit out
You should be able to run the command psql
now and have permissions to create/modify/delete databases and roles.
$ sudo su - postgresql
$ createuser --interactive
(enter your machine username at the first prompt and y at the second)
$ createdb yourusername
$ exit
$ psql
//This will allow you to be able to run this psql command as your user and connect to Postgres