Last active
August 17, 2018 10:12
-
-
Save rusllonrails/5894873 to your computer and use it in GitHub Desktop.
SETUP POSTGRES on UBUNTU
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOURCE: | |
http://hexvolt.blogspot.ru/2012/11/postgresql-91-ubuntu-1204.html | |
1.) Install | |
sudo apt-get update | |
sudo apt-get install postgresql-9.1 | |
2.) Set new password for postgres user | |
sudo passwd postgres | |
3.) prepare db claster and add to PATH variable path to claster (directory for db storing) | |
su postgres | |
mkdir /var/lib/postgresql/data | |
sudo gedit /etc/environment | |
PATH="/usr/bin:/usr/lib: ........:/usr/lib/postgresql/9.1/bin" | |
and to the last line of this file put: | |
PGDATA = "/var/lib/postgresql/data" | |
Then restart the computer. | |
4.) Make initdb | |
su postgres | |
initdb -D /var/lib/postgresql/data | |
5.) Run postgres | |
pg_ctl -D /var/lib/postgresql/data start | |
if it FAILS like this: | |
server starting | |
LOG: could not bind IPv4 socket: Adress already in use | |
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. | |
WARNING: could not create listen socket for "localhost" | |
FATAL: could not create any TCP/IP sockets | |
It seems that this process already started after installing | |
Just keek this process using kill and ps aux | grep postgres | |
and then run again | |
pg_ctl -D /var/lib/postgresql/data start | |
6.) Add postgres start to rc.local | |
sudo gedit /etc/rc.local | |
and then put this to the bottom before exit line: | |
su -c 'pg_ctl start' postgres | |
7.) create your first database: | |
su postgres | |
createdb mydb | |
8.) And install pgadmin | |
sudo apt-get install pgadmin3 | |
9.) add to Gemfile | |
gem 'pg' | |
10.) add to database.yml | |
development: | |
adapter: postgresql | |
encoding: unicode | |
database: mydb_dev | |
pool: 5 | |
username: postgres | |
password: yourpostgrespassword | |
and run rake db:create |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment