How to Install PostgreSQL 10 in Windows 10 and Linux
Mini Bytes: In this tutorial i am going to explain you about how to install PostgreSQL 10 in windows 10 and Linux operating system. Since there are many ways to install PostgreSQL 10, i am going to follow GUI installation in Window 10 and command line installation in Linux (Ubuntu 17.04 & CentOS 7).
As the first step i am going to show you how to install PostgreSQL 10 in windows 10.
How to install PostgreSQL 10 in Windows 10:
Before installing PostgreSQL 10 in windows 10, we need to get the PostgreSQL setup file. For this we need to go to the installer provider. Currently there are 2 installers available.
I prefer Enterprise DB because starting from the first i am using the enterprise DB package and found not issues while installing the PostgreSQL database.
Enterprise DB is providing all the required packages available for all the platforms such as windows, linux in both 32-bit and 64-bit.
You can download PostgreSQL 10 package for windows 10 from here.
Here is a simple video tutorial for you on installing PostgreSQL 10 in windows 10.
Location: Postgresql 10 from windows 10
If you are using 64-bit version of windows then you need to install 64-bit version of postgresql 10 to get full featured performance. You can also install 32-bit version of postgresql 10 in 64-bit version of windows 10, but you may face some performance degradation.
postgresql 10.1 is the latest major release and it has more features that improves the performance of queries. Below are some of the major features which was available the postgresql 10.1.
Major enhancements in PostgreSQL 10 include:
- Logical replication using publish/subscribe
- Declarative table partitioning
- Improved query parallelism
- Significant general performance improvements
- Stronger password authentication based on SCRAM-SHA-256
- Improved monitoring and control
Though you may consider this release as the major release from PostgreSQL 9.6 to 9.10, logical replication and declarative table partitioning is considered to be the useful feature in this release for me.
Its because, when i ran the performance check between both the versions i can see only 2 to 3 milliseconds of difference between 9.6 and 9.10. Lets go in to the installation part.
As the first step when you start the installation, it will check for the Microsoft Visual C++ 2013 redistributable package. You need to install this package manually if you are using PostgreSQL binary installation package.
You can get the package from here Microsoft Visual C++ 2013
In this step, you need to select the “Next” button.
In the next step, you need to specify the installation directory for PostgreSQL 10. But default it will point to the below directory location
If you need to change the location path, then you can change the location path. Keep in mind, this path is different from the data directory path where the actual database files gets stored.
In this step, leave it as it is or change the required location and select “Next”.
Here you can install the following components.
- PostgreSQL 10 Server
- Stack Builder
- Command Line Tools
If you are a database administrator, all the above mentioned tools are important, but if you are going to test or learn about PostgreSQL 10, then you may need only the first two tools.
PgAdmin is the latest tool which you can use to browse the database visually. I has lot more features when compared to the previous version. But i recommend you to use global database browser tools, because it provides more features when compared to PgAdmin 4. I will go for all the components.
Here, select the features you need and select the button “Next”.
This is the main part during the installation, because this is the place where you need to select the data directory where the PostgreSQL database files resides.
You need to make sure that, the drive which you are specifying here should have maximum free space if you are going to use the PostgreSQL in production.
Here important configuration files such as pg_hba.conf and postgresql.conf files will be deployed by the installer.
Here i am going to leave it as it is because i am having enough space in my c drive for PostgreSQL 10 installation.
In this step can specify the location for the data directory or leave it as it is and select the “Next” button.
In this step you need to provide the password for the default account “postgres”. This account will be created during the installation of PostgreSQL 10. So you don’t need to create any specific account for login.
You can also create different users after the installation using PgAdmin 4 or by any other database browser.
Please give a strong password to secure our database.
In this step give strong password in both the text box and select “Next”.
Here, you need to select a port which PostgreSQL 10 use to communicate over the network. By default PostgreSQL uses 5432 port and if you need to be secure, then you can manually specify a valid port in this step.
Here i am going to leave it with the default port 5432.
In this step, specify the port number and hit “Next”.
In the next step, specify the locale i.e. language which you are are going to use in the PostgreSQL 10. I will leave it as default.
In this step select the language and select “Next” button.
This is the last step and here you can see the installation options which you have selected in the previous sections. If you found anything wrong or if you want to change any installation settings then you need to go back and make the changes.
Installation Directory: C:\Program Files\PostgreSQL\10
Server Installation Directory: C:\Program Files\PostgreSQL\10
Data Directory: C:\Program Files\PostgreSQL\10\data
Database Port: 5432
Database Superuser: postgres
Operating System Account: NT AUTHORITY\NetworkService
Database Service: postgresql-x64-10
Command Line Tools Installation Directory: C:\Program Files\PostgreSQL\10
pgAdmin4 Installation Directory: C:\Program Files\PostgreSQL\10\pgAdmin 4
Stack Builder Installation Directory: C:\Program Files\PostgreSQL\10
So if you are OK with the PostgreSQL 10 settings, then you can hit “Next” to proceed the installation.
After the installation completes, you can login into the PostgreSQL 10 using the PgAdmin 4 with the following username “postgres” and password which you have specified during the installation.
Now lets see how to install PostgreSQL 10 in Linux. Here we are going to see how to install PostgreSQL 10 in Ubuntu and also we can see how to install PostgreSQL 10 in CentOS 7
Below is a simple video tutorial on installing PostgreSQL 10 binaries in Window 10.
How to install PostgreSQL 10 in Linux:
If you want to install PostgreSQL in GUI mode then you need to download PostgreSQL 10 for Ubuntu and CentOS 7. From the below link you can download the packages for both the distributions.
If you are planning to install PostgreSQL 10 in Ubuntu 17.04 and CentOS 7 using the online repository, then you don’t need to download the packages.
Install PostgreSQL 10 in Ubuntu 17.04:
Inorder to install Postgresql in ubuntu, as the first step you need add the repository content in the repository file to download the content from online repository.
Below are the steps to create the repository in Ubuntu 17.04 and install it.
After opening the Terminal in Ubuntu, you must create repository file.
After creating the file add the following lines in to the file pgdg.list
For Ubuntu 17.04:
deb http://apt.postgresql.org/pub/repos/apt/ zesty-pgdg main
For Ubuntu 16.04:
deb http://apt.postgresql.org/pub/repos/apt/ zesty-pgdg main
For Ubuntu 14.04:
deb http://apt.postgresql.org/pub/repos/apt/ <span id="series-deb">trusty</span>-pgdg main
Now you must import the repository signing key using the command below.
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
if you have successfully imported the signing key, then you must update your ubuntu using the following command.
sudo apt-get update
You have successfully added apt repository for PostgreSQL. Now use the following command to install the PostgreSQL server in Ubuntu.
apt-get install postgresql-10
You may need to give password when it asks you, after that it will create all the data folders, postgres user etc.
Note: It will install the PostgreSQL 10 with the default settings such as port (5432), data directory location etc. If you want to change the default settings, then you need to make modifications in postgresql.conf file.
Install PostgreSQL 10 in CentOS 7:
In order to install Postgresql 10 in CentOS 7 distribution, you first need to install the rpm repository for postgresql-10. With the help of the below command, you can install the rpm repository.
yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-1.noarch.rpm
Note: This RPM repository may vary depending on the distribution you are using. For fedora related distribution you can refer this link to get the appropriate rpm repository.
If you have successfully installed the rpm repository for PostgreSQL 10, then you can start the installation with the help of below command.
yum install postgresql10
After the installation completes, you need to run the below command to initialize the database. This step will ask you the port number, data directory location, installation location etc.
After giving the required settings, you need to restart the postgresql-10 service using below command.
systemctl enable postgresql-10
systemctl start postgresql-10
To make sure the service is on after rebooting the server you need to use the following command. If not then you need to start the PostgreSQL 10 server every time you reboot your server.
systemctl postgresql-10 enable
So these are the simple steps which you can use to install PostgreSQL in your windows 10 and Linux (Ubuntu & CentOS). If you like the post please share and please leave your comments below.
Below is a simple video tutorial on installing PostgreSQL 10 in linux.