5

mac os x lion 10.7.4

psql --version -> psql (PostgreSQL) 9.0.5

I want to install latest version and run my rails app with it.

I do

brew install postgresql

it is installed here: /usr/local/Cellar/postgresql/9.1.4  

initdb /usr/local/var/postgres

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

I get:

pg_ctl: another server might be running; trying to start server anyway

running postgres --version

 -> 9.1.4

postgres -p 5433

 postgres does not know where to find the server configuration file.
 You must specify the --config-file or -D invocation option or set the PGDATA environment variable.

2 Answers 2

5

Edit /usr/local/var/postgres/postgresql.conf and change the port directive to use a different port number like 5433. Then start the new Pg instance as you did before.

You can now connect to the 9.1 instance by specifying a different port in your Rails configuration.

Sign up to request clarification or add additional context in comments.

6 Comments

i changed the port and ran the server again but its not changing. can you please give me a bit more details on how to do this.
@Beamon ... did you change your rails setup to connect to the new port in database.yml?
I'm not even connecting to the 9.1.4 instance yet... after I change the conf file to port # to 5433 and save. Starting the pg instance is not connecting to the right instance. Don't I need to connect to the right instance before I worry about my database.yml and rails configuration?
@Beamon Connecting with what? Do you mean psql? Struggling to understand your comment. You need to (a) Start the new Pg on a different port; and (b) connect to it by specifying the new port. For psql that'd be psql -p 5433 for example.
@Beamon Run the version of psql that was installed by the new PostgreSQL. You may need to set your PATH or use an explicit path. To get the version of the server you're connected to use select version();
|
5

In MAC:

brew link --overwrite -f [email protected]

will change default psql version on terminal psql command.

You will also find all postgresql version folders in /usr/local/Cellar/

Examples:

/usr/local/Cellar/postgresql/12.3_4

/usr/local/Cellar/[email protected]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.