Install Postgre on Ubuntu 18.04
Feb 17, 2021
- Add PostgreSQL repository
Execute below 3 commands to add PostgreSQL repository.
>> sudo apt-get install wget ca-certificates>> wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
>> sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
2. Install PostgresSQL
>> sudo apt-get update>> sudo apt-get install postgresql postgresql-contrib
By default, PostgreSQL creates “postgres” if PostgreSQL has been installed successfully.
3. Check the installed PostgreSQL version
>> apt show postgresql
4. Connect to PostgreSQL
>> sudo -u postgres psql
5. Check connection information
Once you connect to the PostgreSQL server, you can use the below command to check connection information.
\conninfo