Introduction
Let's Get Our Hands Dirty!
Hey there, Linux adventurer!
Thinking of installing PostgreSQL on your server?
Well, you're in the right place and don't worry, we're not just going to throw terminal commands at you and disappear.
This guide is interactive you’ll read, you’ll type, you’ll feel powerful.
What is PostgreSQL anyway?
PostgreSQL (or Postgres) is a free, open-source, object-relational database that powers web apps, enterprise systems, and even scientific research. In short if you’ve got data, Postgres can handle it.
So before we jump in, ask yourself:
- Do you have terminal access (with sudo)?
- Are you working on a fresh Linux install or an existing server?
- Do you know how to copy paste without breaking things?
If your answers are mostly “yes,” then high five!
Let’s get your Linux box speaking fluent PostgreSQL.
“The best way to learn is to do. So open that terminal we’ve got some commands to run.”
- System Update Command: 1. System UpdaCommand: sudo apt update && sudo apt upgrade -y This command updates your system package list and installs the latest versions of all packages. It ensures your system is ready for PostgreSQL.
bash
Copy
Edit
Install PostgreSQL
Command: sudo apt install postgresql postgresql-contrib -ySwitch to PostgreSQL User and Access Shell
Command: sudo -i -u postgres → psqlSet PostgreSQL Password
Command inside psql: \password postgresCreate Database and User
SQL Commands:
sql
Copy
Edit
CREATE DATABASE testdb;
CREATE USER testuser WITH ENCRYPTED PASSWORD 'yourpassword';
GRANT ALL PRIVILEGES ON DATABASE testdb TO testuser;
- Edit Config for Remote Access Command: sudo nano /etc/postgresql/14/main/postgresql.conf
Command: sudo nano /etc/postgresql/14/main/pg_hba.conf
- Restart and Check Status Command: sudo systemctl status postgresql
Conclusion
You’ve now successfully installed and set up PostgreSQL on your Linux server. With just a few commands, your system is ready to store, manage, and query data efficiently. PostgreSQL is powerful, secure, and ideal for both small projects and large applications. Keep exploring its features to get the most out of your database setup.
Top comments (0)