Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 540 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Installing PostgreSQL on Ubuntu for Ruby on Rails

#1
I currently have Ruby on Rails installed via RVM in Ubuntu 12.04. The default database is set up in SQLite3, but I'd like to switch to PostgreSQL for the purposes of pushing to Heroku. How can I accomplish this?
Reply

#2
sudo sh -c "echo 'deb

[To see links please register here]

precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list"

wget --quiet -O -

[To see links please register here]

| sudo apt-key add -

sudo apt-get update

sudo apt-get install postgresql-common

sudo apt-get install postgresql-9.3 libpq-dev
Reply

#3
Here are the steps I've followed:

_Install PostgreSQL and development package_

$ sudo apt-get install postgresql
$ sudo apt-get install libpq-dev

_Set up a user that is the same as my Ubuntu log-in_

$ sudo su postgres -c psql
postgres=# CREATE ROLE <username> SUPERUSER LOGIN;
postgres=# \q

_Modify Gemfile_

# Remove gem 'sqlite3'
gem 'pg'

_Modify `database.yml` in app directory_

development:
adapter: postgresql
encoding: unicode
database: appname_development
pool: 5
timeout: 5000
username: <username>
password:

test:
adapter: postgresql
encoding: unicode
database: appname_test
pool: 5
timeout: 5000
username: <username>
password:

_Run bundle install_

$ bundle install

_Create databases and migrations_

$ rake db:create:all
$ rake db:migrate

Here are the sources I used to help:

[To see links please register here]

[To see links please register here]

[To see links please register here]

Reply

#4
For all `Ubuntu 13.10` users that open this thread follow the steps below to install `postresql`:

sudo sh -c "echo 'deb

[To see links please register here]

precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O -

[To see links please register here]

| sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-common -t saucy
sudo apt-get install postgresql-9.2 libpq-dev

since there isn't an official Postgres repository for `Ubuntu 13.10`.

Then create the user as `Nick` explain (you can specify a password too):

sudo su postgres -c psql
postgres=# CREATE ROLE gotqn SUPERUSER LOGIN;
postgres=# \password gotqn
postgres=# \q

Note: Replace the `gotqn` above with `whoami` result:

![enter image description here][1]

The easiest way to create your rails application is to specify you are using `postgresql` as follows:

rails new Demo -d postgresql

The code above will automatically add the `pg` gem in your `GemFile` and create appropriate `database.yml` file:

development:
adapter: postgresql
encoding: unicode
database: Demo_development
pool: 5
username: gotqn
password: mypass

Note: You need to change the username and to specify the correct password if you have set such.

Then run `rake db:create` and start the rails server.

[1]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through