Installing database software like PostgreSQL, Oracle, or SQL Server can seem like a complicated task, but it really isn’t! These days, most relational database management systems come with installation wizards that make the process much simpler. In this article, we’ll look at how to install PostgreSQL and test that the installation is working.
Overview: PostgreSQL Installation Steps
We’ll complete the following tasks:
- Downloading the PostgreSQL package.
- Installing and configuring PostgreSQL.
- Starting the postgres server application.
- Verifying that PostgreSQL is working.
PostgreSQL is available on Linux (or Unix), Windows, and macOS platforms. We’ll install and configure it on Windows 10.
1. Downloading the PostgreSQL Package
That’ll take you to the following page:
Here, you’ll need to select the postgres version to download and your operating system. In this article, we’ll work with PostgreSQL version 10 (which, as of now, is the latest available) and a 64-bit Windows 10 operating system.
Click the download button to continue. Once it finishes, you’ll be directed to the following page:
Click the installer that pops up in the bottom-left of your browser (you’ll see it there if you’re using Chrome—if not, double-click the installer from your Downloads folder).
2. Installing and Configuring PostgreSQL
The installation process will include the configuration of some important parameters like the port number, your postgres admin password, and more. Don’t worry if you don’t know what any of these things mean! The installation is straightforward.
To start, click Next in the following window.
Choose the directory where you want PostgreSQL to be installed. It’s recommended that you leave the default as it is. When you’re done, click Next.
The next page shows the components that are going to be installed. Leave these options checked as they are, and click Next again.
Leave the data directory as the default, and click Next.
At this point, you need to choose a password for postgres superuser (administrator) permissions. This password will be used when you connect as the user “postgres” from the SQL client in the verification section at the end of this guide. Click Next when you’re done.
Then, you’ll need to choose the port number that the postgres server will listen to for requests. The default is 5432, but the installation wizard may suggest another if 5432 is already in use. Click Next to continue.
Now, you should see a summary of all parameters you set in the previous steps. Click Next again to move on.
On the following page, simply click Install.
You should see a progress bar like the one below as PostgreSQL is installing.
When the installation is complete, you should see the following window:
Stack Builder is optional. Click Finish, and you’re done!
3. Starting PostgreSQL as a Server
After you install PostgreSQL, the software will automatically start. And whenever you restart your computer, postgres will start as well.
However, at any time, you can choose to stop or start the postgresql server yourself. There are a few ways to stop postgresql; the simplest is through Task Manager.
If you navigate to the Services tab, you’ll see the following. On my notebook, I have two postgresql versions installed (10 and 9.6). One is running and one is stopped.
Here, you can start or stop postgres at any time by right-clicking it and selecting the desired action.
4. Verifying Your PostgreSQL Installation
Whenever you install software, it’s always a good idea to verify that the installation was in fact successful. One way to verify the postgresql installation is by connecting to postgresql from any SQL client. PostgreSQL comes with the official pgAdmin client as part of the default installation.
Start the pgAdmin application. Then, click File and select Add Server.
In the window that appears, you’ll see a list of properties you can specify. The password is the same one you chose during your postgres installation.
If the connection is successful, you should see something like the following, with PostgreSQL actively listening to the port it connected to.
Congratulations! You’ve successfully installed PostgreSQL and verified that it’s working properly. Now, you can begin creating your own databases and running SQL queries in pgAdmin. Have fun!