install postgres on linux
- Update the package list:
sudo apt update
- Install PostgreSQL:
sudo apt-get install postgresql
- Verify the installation:
psql --version
- Start and enable PostgreSQL service:
sudo systemctl start postgresql sudo systemctl enable postgresql
- Configure PostgreSQL:
Open the PostgreSQL configuration file:
sudo nano /etc/postgresql/
Update the following lines:
- Uncomment the line "listen_addresses = 'localhost'" to allow connections from the local machine.
- Uncomment the line "max_connections = 100" to set the maximum number of connections.
Save and exit the file.
Create a new PostgreSQL user:
sudo -u postgres createuser --interactive
Follow the prompts to create a new user with desired privileges.
- Create a new PostgreSQL database:
sudo -u postgres createdb
Replace "
- Connect to the PostgreSQL database:
sudo -u postgres psql
You will now be in the PostgreSQL command-line interface.
- Perform further configuration or setup as needed.
Remember to adjust the commands and file paths based on your specific Linux distribution and PostgreSQL version.