Skip to content

Instantly share code, notes, and snippets.

@madis
Last active December 21, 2015 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madis/6240947 to your computer and use it in GitHub Desktop.
Save madis/6240947 to your computer and use it in GitHub Desktop.
OS X installing postgres. Setting up postgres roles and database
# 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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment