Installing psql(11.5) with hombrew, setting up PgAdmin and Postgres.app
Tags: terminal, backend, database, postgres
Published: 2019-09-18 19:02:10

---
title: Installing psql(11.5) with hombrew, setting up PgAdmin and Postgres.app
published: true
description: initial setup guide to get started with psql & homebrew 
tags: terminal, backend, database, postgresql
cover_image: https://thepracticaldev.s3.amazonaws.com/i/xkrt0qrf6d1c5sa93nbz.jpg
---

#The Gist

I've been going through and cleaning up my system, updating the tools, frameworks and languages that I have installed on my local machine.

While doing this, I realized I had never installed postgresql through the package manager, Homebrew. And since as of this moment, I don't have any critical projects using my local setup, I decided to go through the pain of setting up things right once, so that I don't have to worry about it in the future when wanting to easily update or remove any packages.

##The Why

[Homebrew](https://brew.sh/) is like NPM or Rbvm in the sense that it's a package manager, meant to help you easily update, remove, or add packages. 

> Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's macOS operating system and Linux. The name is intended to suggest the idea of building software on the Mac depending on the user's taste. Originally written by Max Howell, the package manager has gained popularity in the Ruby on Rails community and earned praise for its extensibility.[3] Homebrew has been recommended for its ease of use[4] as well as its integration into the command line.[5] Homebrew is a non-profit project member of the Software Freedom Conservancy, and is run entirely by unpaid volunteers.[6] - per [wikipedia](https://en.wikipedia.org/wiki/Homebrew_%28package_management_software%29)


##The How

First I needed to figure out how to delete my original install that's not through Homebrew.

Let's back things up

![](https://media.giphy.com/media/3oFzlVGQcWiBp9Kcve/giphy.gif)
<figcaption>NSFPW: not safe for puppy work</figcaption>

```bash
 🜲  pg_dump -d informo-backend_development -n public -f informee-backend.sql
```

Now you have your back up of a singular database.
We can worry about this later on, when we need to import it back.
But for now, we can celebrate that we did one thing right, hurrrray!

Next, uninstalling postgresql from your machine. We should check which version of psql you have installed using the command

```bash
psql -I -version
```

Mine was 10.10 so I then ran the command

```bash
open /Library/PostgreSQL/10.10/uninstall-postgresql.app
```
But I got an error that said I didn't have that installed there.
I took a short cut and used my [AppCleaner](https://freemacsoft.net/appcleaner/) app that located where all the files where after dragging and dropping my app. Also as a side note, I ended up getting the yearly subscription for [CleanMyMac X](https://macpaw.com/) after diving in to see if there was a better alternative.

Always run `brew update` before installing and then 

```bash
brew install postgresql
```

after which you can run `which psql` to check the version that was installed.

##The Issues Log

Here's areas where I ran into problems

1) Adding the [Postgress App]( https://postgresapp.com/ )

When I downloaded the app after installing the latest psql version through homebrew, I kept getting an error stating `Binaries not found`.

I thought it was a million things like, I had deleted the wrong core files, installed in the wrong place due to homebrew, etc. I wondered if it was even possible to run the app alongside the homebrew installation r if I was just going got have to default to using the installer like a noob.

After much searching through stackoverflow and the like, I found this 
 [Upgrading from pre 9.5 instructions are not clear #399](https://github.com/PostgresApp/PostgresApp/issues/399)

Which all grunting aside was pretty great, I realized I had to click the side tab and the create a new server. That was it! Apparently the default server it came with was pointing to the psql -v 10 and I need 11, which creating a brand new server solved.

![ded](https://media.giphy.com/media/NQRRqqkImJ3Da/giphy.gif)
<figcaption>ahhhh</figcaption>

2) Setting up [PgAdmin](https://www.pgadmin.org/)

The core of the issue was this, after installing, opening a new window and entering my default password, I went ahead and tried adding my server. Thankfully, this stackoverflow post helped me [pgAdmin and PostgreSQL: can't connect to server](https://stackoverflow.com/questions/16889400/pgadmin-and-postgresql-cant-connect-to-server)

But everytime I entered my hostname, and the server name, I got a `connection refused` error.

Okay let's open up the database from the Postgress App we just got working.

Click on a database and a terminal window opens. You're in the matrix.

Now we type

```sql
SHOW port;

 port 
------
 my_port_number_here
(1 row)
```

Cooool. How about the host name? 


```sql
SHOW listen_addresses;

 listen_addresses 
------------------
 localhost
(1 row)
```

Oh, I was using my machine name and not the `localhost`...

![ded](https://media.giphy.com/media/eBCnpuRGBhQGY/giphy.gif)
<figcaption>Don't mind me, just going around in circles with myself</figcaption>

Once I added the correct info, the database gates opened and I had my db's showing on the page.

Below I've added two other links that would be helpful in getting setup, [remove_postgres_on_mac_os.md](https://gist.github.com/Atlas7/b1a40a2ffd85728b33e7) and ["how to start a postgresql server on macos"](https://dataschool.com/learn-sql/how-to-start-a-postgresql-server-on-mac-os-x/)

Photo by <a style="background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, &quot;San Francisco&quot;, &quot;Helvetica Neue&quot;, Helvetica, Ubuntu, Roboto, Noto, &quot;Segoe UI&quot;, Arial, sans-serif;font-size:12px;font-weight:bold;line-height:1.2;display:inline-block;border-radius:3px" href="https://unsplash.com/@davidclode?utm_medium=referral&amp;utm_campaign=photographer-credit&amp;utm_content=creditBadge" target="_blank" rel="noopener noreferrer" title="Download free do whatever you want high-resolution photos from David Clode"><span style="display:inline-block;padding:2px 3px"><svg xmlns="http://www.w3.org/2000/svg" style="height:12px;width:auto;position:relative;vertical-align:middle;top:-2px;fill:white" viewBox="0 0 32 32"><title></title><path d="M10 9V0h12v9H10zm12 5h10v18H0V14h10v9h12v-9z"></path></svg></span><span style="display:inline-block;padding:2px 3px">David Clode</span></a> on Unsplash