Saturday, March 15, 2008

Postgres + Rails + Ubuntu Troubleshooting

Problem 1 - forgotten password for postgres

Solution - TOUGH! you gotta re-install, that's what happened to me

Problem 2 - sudo apt-get remove postgresql did not remove any of the configuration files

Solution - use apt-get purge postgresql instead, this applies to all other packages

Problem 3 - sudo apt-get purge postgresql did not remove all the associated files

Solution - use sudo apt-get purge postgresql* instead or you can run apt-get autoclean after

Problem 4 - postgres refuses connection, but I swear I entered the password correctly!!!

Solution - postgres is very protective, the account you are logging in must match your current linux account .

Problem 5 - But what if I want postgres to manage its own account?

Solution - edit /etc/postgresql/8.1/main/pg_hba.conf, look near the bottom of the file, modify "Unix domain Socket" to local all all md5, "IPv4 local connections" to host all all 127.0.0.1/32 md5

and don't forget to restart the server by doing /etc/init.d/postgres-8.2 restart

Problem 6 - I installed postgres-pr but rails can't connect to postgres and I tried installing the
regular postgres gem but it failed!

Solution - in order to install the postgres gem, make sure you have the libpq-dev gem installed first. (gem install libpq-dev). Try installing the postgres gem again, it should work!

Problem 7 - I want postgres to run on some other port, what can I do?

Solution - first edit the /etc/postgresql/8.2/main/postgresql.conf, change the port number there first (don't forget to restart the server) then you have to goto your rails directly and edit config/database.yml, add ":port [portnumber]" to all your environments.


J

No comments: