Postgres

## Install Postgres ``` brew install postgresql brew services restart postgresql@14 > postgres --version > postgres (PostgreSQL) 14.7 (Homebrew) ``` ```bash ==> postgresql@14 This formula has created a default database cluster with: initdb --locale=C -E UTF-8 /usr/local/var/postgresql@14 For more details, read: https://www.postgresql.org/docs/14/app-initdb.html ``` ## Connect to postgres ``` brew services start postgresql psql postgres ``` ## Create a role ```bash postgres=# CREATE ROLE postgres WITH LOGIN PASSWORD '123456'; CREATE ROLE postgres=# psql postgres -U postgres postgres-# \du List of roles Role name | Attributes | Member of ------------+------------------------------------------------------------+----------- dongweilai | Superuser, Create role, Create DB, Replication, Bypass RLS | {} postgres | | {} ``` ## Connect to pgAdmin4 ``` password for pgAdmin4: laiweidong234 / 123456 password for postgres: 123456 (username: postgres) ```