Homebrew Install PGSQL

165 阅读1分钟

PGSQL installation via Homebrew

In case it will be an obstacle for me again. I write it down in here.

A Case in Nodejs(koa2 + ts)

click here

Install homebrew

what is it?

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Install PGSQL

# instlal binary file
brew install postgresql

# initialize database
initdb /usr/local/var/postgres

# start postgresql server
postgres -D /usr/local/var/postgres

# create your own databse
createdb mydb

Start Your DB Voyage

psql mydb

Create User

# create user
createuser -P my_user_name

# grant all privileges
GRANT ALL PRIVILEGES ON database mydb TO my_user_name;

Stop Server

# stop serve
pg_ctl -D /usr/local/var/postgres stop

Remover Old Configurations

THIS COULD BE DANGEROUSLY, USE IT CAREFULLY!

# remove old db files
rm -rf /usr/local/var/postgres