This is geared toward debian linux users.
sudo -u postgres psql
~/repos/chorelist$ sudo -u postgres psql psql (14.6 (Ubuntu 14.6-0ubuntu0.22.04.1)) Type "help" for help. postgres=#
\?
: list of possible commands and short descriptions. This should be in a less
-type interface. This means you can search with /
followed by your search term.\l
: list current databases.\du
: list roles (aka users) and their permissions.\q
: exits the postgres interface.create user username with encrypted password 'password';
creates the user.alter user username CREATEDB;
At this point you need to set up your application so that it can connect to the database.
Gemfile
(e.g. gem "pg"
)config\database.yml
to look something like this.default: &default adapter: postgresql encoding: unicode pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> username: db_username password: db_password timeout: 5000 development: <<: *default database: app_development host: localhost test: <<: *default database: app_test host: localhost # Omitting the production section as that will vary on your deployment setup.
bundle exec rails db:create
, and rails will create your development and test databases if you did everything correctly.psql
and use the \l
to see if those databases are now listed.