If you want to install Postgres on your Mac,
you’ve got two options - the installation package or using Homebrew.
In this video, I’ll show you how to install it using the installation
package. We will then connect to it using the editor called pgAdmin.
Let’s get started.
The first step is to download the installation package.
Start by visiting the Postgres website at postgresql.org
Click on the Download button at the top of the screen.
On the Download page, click on the macOS button under the PostgreSQL Downloads section.
On the macOS Packages page that loads, click on the “Download the installer”
link under the “Interactive installer by EDB” section.
You’ll be taken to a site called Enterprise DB which hosts the Postgres installation packages.
Click the button under the Mac OS X column for the version you would like. The version numbers
shown here may be different to the ones you see, as newer versions are added over time.
For this demo, I’ll click the button for the 14.5 version.
Select a location to save the installation package, and click Save.
The file will then begin downloading. It’s about 300 MB so may take a little while,
depending on your connection speed.
Once the installation package is downloaded, you can open it. The file will be verified.
After it is verified, a folder will be displayed with another file.
Double-click on the postgres file in the window.
If a warning appears about the file being downloaded from the Internet, click Open.
Enter your account password if you are prompted.
You’ll then see a splash screen for a moment.
Once the splash screen has loaded, you’ll see the PostgreSQL Setup Wizard.
Click Next on the welcome screen. You’ll see the Installation Directory screen.
Leave the default directory and click Next. You’ll see the Select Components screen.
You can deselect any that you don’t want, but for this demo we’ll leave them all selected.
You’ll need the PostgreSQL server, and you’ll want to install pgAdmin to connect to the database.
Command Line Tools are also required.
So, leave the defaults, and click Next.
You’ll then see the Data Directory screen.
Leave the default values here and click Next.
You’ll see the Password screen.
Enter a password to use for the postgres user on the database, and click Next.
You’ll need to remember this password for when you connect to the database later in this video.
You’ll then see the Port screen.
By default, the installer will use port 5432. It
may detect that this port is in use, and change it to 5433.
In either case, click Next.
You’ll then see the Advanced Options screen. Leave the default locale selected, and click Next.
Next is the Pre Installation Summary screen. Click Next.
You’ll then see the Ready to Install screen. Click Next to begin the installation, and it will begin.
The installation should complete in about two minutes.
Once it is complete, you’ll see the Completing the Setup Wizard screen.
It says that setup is complete and asks if you want to run Stack Builder.
Uncheck “Launch Stack Builder” and click Finish.
Postgres is now installed on your Mac!
The next step is to connect to the database.
You can connect to this database using the pgAdmin tool that was installed with Postgres,
or you can use another IDE such as DBeaver.
We’ll use pgAdmin in this video.
To open pgAdmin, search for it using Spotlight, or go to Finder,
then Applications, then PostgreSQL 14.
Open the pgAdmin 4 application.
You’ll see a splash screen for a moment while it loads.
You’ll be prompted to provide a master password.
This is a password used by pgAdmin to access all of the databases that you set up.
It’s different to the postgres password you specified when you installed postgres.
The master password is strongly recommended by the pgAdmin team
because of the way the application works and to add more security.
So, enter a master password you want to use, and click OK.
The pgAdmin main screen will then be displayed.
Expand the Servers section on the left of the screen.
There should be at least one entry shown here. pgAdmin will automatically detect any Postgres
installations and create a server entry (which represents a database connection).
I’ve got a couple listed here because I’ve set them up for other connections,
but you will likely only see one for the Postgres version you just installed, such as Postgres 14.
Double-click on the PostgreSQL 14 entry.
You’ll be prompted to enter the password.
Enter the password you provided during the
PostgreSQL installation – the one you needed to remember for later.
Check the Save Password box if you want pgAdmin to store the password,
so you don’t have to enter it each time you want to connect. Then, click OK.
After a moment, the database will be connected.
The PostgreSQL 14 icon in the Server list will change to an elephant icon,
which is the Postgres logo, to indicate it is connected.
We’ve now connected to the Postgres database we just installed.
That brings us to the end of this tutorial.
If you want to learn more about using pgAdmin, check out my tutorial video here.
If you want to learn more about databases and SQL, visit my website at databasestar.com.
If you enjoyed this video, subscribe to my channel.
Thanks for watching.