Skip to content

Instantly share code, notes, and snippets.

@ahasverus
Last active April 14, 2020 14:12
Show Gist options
  • Save ahasverus/43a7c523cd880399f4c313ed8edf4127 to your computer and use it in GitHub Desktop.
Save ahasverus/43a7c523cd880399f4c313ed8edf4127 to your computer and use it in GitHub Desktop.

PostgreSQL Command Lines

$ brew install postgresql                                     # Install PostgreSQL

$ /usr/local/opt/postgres/bin/createuser -s postgres          # Create postgres role
$ psql -U postgres                                            # Connect to PostgreSQL
postgres=# \password postgres                                 # Set/change password for postgres

$ brew services start postgresql                              # Start PostgreSQL server

$ createdb database_name                                      # Create a new database
$ psql database_name < dump_file.sql                          # Restore previous backup
$ pg_dump database_name > dump_file.sql                       # Backup database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment