Downloading and Installing Postgresql On Windows 10
Downloading and Installing Postgresql On Windows 10
Once you're there, click the Download button on the homepage to see various operating
systems that are available for PostgreSQL. You'll see Linux, macOS, Windows, and others.
Selecting Windows from that list will take you to a page that gives you more specifics about Windows
installation.
There's a link at the top of the page for the installer (download the installer) which will take you away
from PostgreSQL.org and over to a page on enterprisedb.com. EDB is one of the main distributors of
PostgreSQL for companies and individuals.
On this page, you'll see a table with various versions of PostgreSQL along the y-axis, and some
Linux, Mac, and Windows operating systems along the x-axis.
For this course, we will be using version 12 of PostgreSQL( 12.9, 275MB), so go ahead and click
the Download button for version 12 under the Windows column, which will start the download.
****************************************************************************************************************
Now that the installer is launched, you can go ahead and start clicking through the wizard for the
installation. Most of these default values are going to stay the same. The installation directory can
stay the same, but on the second page where it prompts you to select components,
I want you to unselect pgAdmin 4. Then I want you to click Next, select your data directory.
Next, you'll be prompted to provide a password for the database superuser. The
superuser is a type of administrative account that gets added to your PostgreSQL server
upon installation allowing you to add and delete databases and users and perform various
other administrative functions on the server and across any databases you install.
Go ahead and enter a password that's easy for you to remember and click Next. Select the
port number that the server should be on. You can just keep the default value here. You can
keep the default locale and keep hitting Next until finally the installation begins. This will
take a few minutes.
After the installation is done, the final page of the wizard shows you an option to launch something
called Stack Builder. Unclick this option and then click Finish to complete the installation of
PostgreSQL on your Windows 10 machine.
1
install pgAdmin separately.
Installing it separately from PostgreSQL gives certain advantages when it comes to maintaining the
software, keeping it updated and uninstalling it if you need to.
So for this course, to install pgAdmin, I want you to navigate to pgadmin.org in your browser. And
once you're there, find and select the Download button.
This will take you to a page where just like with the PostgreSQL installation, you're given a
number of operating systems to choose from. Select Windows and then select the latest
version of pgAdmin 4.(6.3)
You'll be taken to another page where you should see an exe or executable file. Go ahead
and select that executable file to begin the download.
******************************************************************************************************************
Once the pgAdmin executable has been downloaded, go ahead and launch the installer.
When the installation wizard is open, go ahead and click Next. Then accept the license
agreement and click Next. Select your destination location.
Select the start menu folder you want to create or don't create a start menu folder. And
then begin the installation. This will take a few minutes.
Once the installation is finished, go ahead and click Finish to wrap up our installation of pgAdmin
4.
Setting Environment
Let’s open up pgAdmin and start taking a look around. I have pinned the pgAdmin
application to my taskbar, but you could also find it by opening up your quick search and
looking for pgAdmin.
When you open pgAdmin, you should be prompted to set a master password. Go ahead and
set a password that's easy for you to remember and select OK.
On the left-hand side, we have a browser panel that allows us to see our PostgreSQL
servers and databases.
On the right hand side, we have our main workspace, which is where we'll be writing SQL
queries and seeing the results.
2
To access the PostgreSQL server, expand the servers node. You'll be prompted for the password
for your Postgres superuser that you created when we installed the server. Enter that password and
you have the option to save it as well. Click OK to proceed.
Now you should see your server and all of the databases inside of it. PostgreSQL comes with
a default database installed already called Postgres. You can ignore this database because
we're not going to use it in the course. To hide the Postgres database, you can just click
the node to collapse it.
Along the top of pgAdmin in blue, you'll see a toolbar. For instance, we can go to the File
menu and select preferences to open our preferences menu which will allow you to do things
like changing the theme of pgAdmin.
For instance, if I go to Miscellaneous and then Themes, I can change my theme from
standard to dark or to high contrast. I'm gonna keep my pgAdmin on the standard theme.
I can also change the user language if I want to. Another helpful feature are the keyboard shortcuts
which you can find throughout the preferences menu.
Once you've made changes to your preferences, you can go ahead and click the Save button.
The blue toolbar on the top also has some other features that we're going to use in this course, such
as using the Object menu to create new databases and using the Tools menu to access different
features of pgAdmin.
Now that we've installed PG admin and connected to our server for the first time, let's install our first
sample database.
Download the sample database's zip file from the start of this module. I've downloaded mine to
my windows desktop. I'm gonna right click on it and then select extract all. This will open up a dialog
where I can unzip the contents into a folder on my desktop. I will keep the default value and click the
extract button to begin the unzip and then a window will appear that shows two files inside of a folder
on my desktop.
You'll notice that both of these files have a TAR suffix or TAR. These files are known as
tarballs. They are compressed backup files of these databases which we can use inside
PG admin to create the databases with just a few simple clicks of a button.
3
******************************************************************************************************************
So I'm going to go back into PG admin and then on my object menu, find the option that says
'create database'. This will open up a dialog where I can name my database. I'm gonna give it the
name DVD Rental.
Keep the owner as postgres, you don't need to change any of these settings. and then
click save. This will create a new database on your server.
Next, right click on the DVD Rental database and then find the option for restore.
Select it and a new dialog will open where you are prompted to restore a database from
a backup file. You can keep the first dropdown as it is and on the file name input, select
the button to the far right side with the three dots in the middle. This will open up a
file picker dialogue where you can find your tarballs and begin the process of restoring
the database. (installation\sample databases\dvdrentals.tar)
You may need to go to the dropdown menu in the lower right corner and change the format
from backup to all files in order to see your tarballs. Once you've done this, select the DVD
rental tarball and then click the blue select button to begin the process of restoring the database.
Once you pick the DVD rental tarball go to the role name, drop down menu and select
postgres from the available options, then click restore.
You'll see a dialog pop up in the lower right corner of PG admin that tells you your progress in
restoring the database. It should only take a few seconds.
Open up the schemas section of your DVD rental database and you should see a public
schema.
Then open up the tables node underneath the public schema and you should see several
tables.
Then to confirm that these tables have data in them, you can right click on one of them, find
the view edit data option, and then select first 100 rows.
PG admin will automatically generate a short blurb of sequel and will display the first 100 rows of data
inside the table that you choose. This just confirms that our installation worked fine on the sample
database, and we are ready to begin working.