How can I install PostgreSQL on the Linux of Amazon instance?
I am a system administrator and I have been tasked with setting up a PostgreSQL database server on a particular Linux of Amazon Instance. How can I install PostgreSQL on that instance?
In the context of AWS, you can download and install PostgreSQL on the instance of AWS Linux by using the several steps which are given below:-
Updating the package Repository
Before starting the installation of PostgreSQL, you should update the package repository so that you can ensure you have the latest information about the package.
“sudo yum update -y”
Install postgreSQL
Now you can install the YUM package manager so that you can install the PostgreSQL server and even client packages:-
CREATE DATABASE dbname;
CREATE USER username WITH ENCRYPTED PASSWORD ‘password’;
GRANT ALL PRIVILEGES ON DATABASE dbname TO username;
Initialize PostgreSQL database
You can initialize the PostgreSQL database by using the command which is given following:-
“sudo postgreSQL-setup initdb”
Start PostgreSQL service
Now you can start the Service of PostgreSQL:-
“sudo systemct1 start PostgreSQL”
Enable PostgreSQL Service
You can enable the PostgreSQL service so that you can start automatically upon system boot:
“sudo system enables PostgreSQL”
Access PostgreSQL
You can also access the PostgreSQL command line interface by using the command of psql:-
“sudo -u postgre psql”
Create database and users
You can create database and users within the psql command line interface by using the command which is given following:-
CREATE DATABASE dbname;
CREATE USER username WITH ENCRYPTED PASSWORD ‘password’;
GRANT ALL PRIVILEGES ON DATABASE dbname TO username;