MacLochlainns Weblog

Michael McLaughlin's Technical Blog

Site Admin

PostgreSQL Native OS X

without comments

Started playing around with a native installation of PostgreSQL on my Mac OS X. I navigated to the PostreSQL page to download the program. I downloaded and installed the PostgreSQL Version 11.

Then, I had to connect as the postgres user and start the server. You do that by opening a Terminal, assume the role of superuser root, and then connect as the postgres user. The commands are:

sudo sh
su - postgres
whoami

As the postgres user, you need to set your $PATH environment variable to include the installation of PostgreSQL. You can use the following syntax to add the default directory to the existing $PATH environment:

export PATH=$PATH:/Library/PostgreSQL/11/bin

You can also add the previous line to the postgres user’s .bashrc file, which you’ll need to manually source. You need source the .bashrc file manually because the postgres user can’t connect directly to the server. You must assume the role of the postgres user from the superuser root.

After you have set the environment, you can start the PostgreSQL server with the following command as the postgres user:

pg_ctl -D /Library/PostgreSQL/11/data -l logfile start

Now, you can connect using pgAdmin 4. That’s it for the basic installation. You should see the following after logging in to the PostgeSQL instance:

Basic pgAdmin 4 Consule Screen

As always, I hope this helps those trying to sort out the process.

Written by maclochlainn

April 18th, 2019 at 12:59 am

Posted in Uncategorized