Create user in postgresql and connect it into rails application

Install Postgresql:-

sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-common
sudo apt-get install postgresql-9.5 libpq-dev
 
The postgres installation doesn't setup a user for you, so you'll need to follow these steps to create a user with permission to create databases. Feel free to replace arvind with your username.
sudo -u postgres createuser arvind -s

 # If you would like to set a password for the user, you can do the following 

sudo -u postgres psql postgres=# \password arvind
 
Come into Rails Application config/database.yml
default: &default
  adapter: postgresql
  pool: 5
  username: 'arvind'
  password: 'arvind'
  timeout: 5000
  host: 127.0.0.1

development:
  <<: *default
  database: db_development
production:
  <<: *default
  database: db_production
Thanks 
 

Comments

Popular Posts

How to pass hash in Postman

nginx: unrecognized service

Bootstrap Select Picker append add new item if search not exist

Reading Excel Sheets using "Roo" gem in ruby on rails

Add CORS to Nginx on AWS Elastic Beanstalk

Enable gzip compression on Elastic Beanstalk with nginx

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

Get video duration by URL in Ruby on Rails

site-enables nginx setting in ruby in rails