In your command-line run the following commands:
brew doctor
brew update
- In your command-line run the command:
brew install postgresql
- mkdir /usr/local/var/postgres; initdb /usr/local/var/postgres
- pg_ctl -D /usr/local/var/postgres start/ pg_ctl -D /usr/local/var/postgres stop
- psql postgres # login mgmt console
- Create role for pheonix use create ROLE health WITH LOGIN PASSWORD 'health'; ALTER ROLE health CREATEDB; ##change default postgres password in ubuntu 1.sudo -u postgres psql 2.postgres=# ALTER USER postgres PASSWORD 'postgres'; ALTER ROLE
- update the config/dev.exs so that phoenix could init db repo for you
config :health, Health.Repo,
username: "health",
password: "health",
database: "health",
hostname: "localhost",
pool_size: 10
- check the db from psql
health-# \l #list the db
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+---------+----------+---------+-------+---------------------
health | health | UTF8 | C | UTF-8 |
postgres | leiding | UTF8 | C | UTF-8 |
postgres=# \c health #switch to the db
You are now connected to database "health" as user "leiding".
\dt # list the table
As the default configuration of Postgres is, a user called postgres is made on and the user postgres has full superadmin access to entire PostgreSQL instance running on your OS by using psql postgres, by default, it don't require password
Details: https://www.postgresql.org/docs/9.3/sql-createrole.html https://www.postgresql.org/docs/9.3/sql-alterrole.html