# Install postgres
brew install postgres
# Create folder for logs
mkdir -p /usr/local/var/postgres/
# Set permissions
chmod 700 /usr/local/var/postgres
# Init data directory (and create default config)
initdb /usr/local/var/postgres -E utf8
# Start postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/log/postgres.log start
# Create user and enter password
createuser youruser -P
# Create database with youruser as the owner
createdb yourdatabase -O youruser
Creating user and database in postgres interactive terminal:
# Start the terminal
psql postgres
Enter the commands as necessary:
CREATE DATABASE my_test_db WITH ENCODING 'UTF8' OWNER lollike;
CREATE USER lollike WITH ENCRYPTED PASSWORD 'kalake';
--- If that user needs to create databases then
ALTER USER lollike CREATEDB;