How to Install PostgreSQL on Ubuntu
Introduction
PostgreSQL is a powerful open-source relational database system. This guide shows you how to install PostgreSQL on your Ubuntu VPS.
Step-by-step Guide
- Update your package list
- sudo apt update
- Install PostgreSQL
- sudo apt install -y postgresql postgresql-contrib
- Check PostgreSQL service status
- sudo systemctl status postgresql
- Switch to the postgres user
- sudo -i -u postgres
- Access the PostgreSQL shell
- psql
- (Optional) Create a new database and user
- CREATE DATABASE mydb;
- CREATE USER myuser WITH ENCRYPTED PASSWORD 'mypassword';
- GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
- \q
- exit
- (Optional) Enable remote access
- Edit
postgresql.confandpg_hba.confas needed, then restart PostgreSQL:n- sudo systemctl restart postgresql
- Edit
Recommendations
- Use strong passwords for all database users.
- Regularly back up your databases.
- Keep PostgreSQL updated for security and performance.
Call To Action
eed a VPS for your PostgreSQL databases? Check out our hosting plans: https://xernode.com/#pricing