Skip to content

Instantly share code, notes, and snippets.

@fdnklg
Last active January 9, 2020 12:15
Show Gist options
  • Save fdnklg/4c77ef8070bdbbf442e34f08fd582132 to your computer and use it in GitHub Desktop.
Save fdnklg/4c77ef8070bdbbf442e34f08fd582132 to your computer and use it in GitHub Desktop.

Basics to setup a Postgres Database

Check if you have installed postgres on your machine first.

# CREATE A PHYSICAL POSTGRESQL DATABASE

initdb /usr/local/var/postgres
# START/STOP A POSTGRESQL DATABASE

pg_ctl -D /usr/local/var/postgres start
pg_ctl -D /usr/local/var/postgres stop
# CREATE THE ACTUAL POSTGRESQL DATABASE

createdb mydatabasename
dropdb mydatabasename
# CONNECT TO YOUR DATABASE ON YOUR LOCAL MACHINE

psql mydatabasename
# CONNECT TO YOUR REMOTE DATABASE VIA COMMANDLINE

psql --host=yourhost.eu-central-1.rds.amazonaws.com --port=5432 --username=user --password  --dbname=dbname

If you want to fill your db with content, you should use a tool like Postico to add your data. First define the columns and their data types. Services like AWS don't allow you to upload files via the CLI.

# CREATE A TABLE IN YOUR DB

CREATE TABLE dbname (colname datatype, lat text, lng text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment