# Installing Postgres via Brew ## Pre-Reqs [Brew Package Manager](http://brew.sh) In your command-line run the following commands: 1. `brew doctor` 1. `brew update` ## Installing 1. In your command-line run the command: `brew install postgresql@15` 2. Run the command: `brew services start postgresql@15` 3. Run the command: ``createdb `whoami` `` 4. Connect to your postgres with the command: `psql` 5. `createuser -s postgres` - fixes `role "postgres" does not exist` 6. Test with `psql` command ``` $ psql psql (14.5 (Homebrew)) Type "help" for help. ibraheem=# exit ``` ## Details ### What is this `ln` command I ran in my Terminal? _from the `man ln` command_ > The ln utility creates a new directory entry (linked file) which has the same modes as the original file. It is useful for maintaining multiple copies of a file in many places at once without using up storage for the ``copies''; instead, a link ``points'' to the original copy. There are two types of links; hard links and symbolic links. How a link ``points'' to a file is one of the differences between a hard and symbolic link. ### What is `launchctl`? _from the `man launchctl` command_ >launchctl interfaces with launchd to manage and inspect daemons, angents and XPC services. ## Commands ### Create database ``` createdb ``` > `createdb mydjangoproject_development` ### List databases ``` psql -U postgres -l ``` ### Show tables in database ``` psql -U postgres -d ``` > `psql -U postgres -d mydjangoproject_development` ### Drop database ``` dropdb ``` > `dropdb mydjangoproject_development` ### Restart database ``` dropdb && createdb ``` > `dropdb mydjangoproject_development && createdb mydjangoproject_development`