To install PostgreSQL on Ubuntu, follow these steps:
- Update the package manager's database:sudo apt-get update
- Install the PostgreSQL package and any required dependencies:sudo apt-get install postgresql postgresql-contrib
- During the installation, you will be prompted to set a password for the default PostgreSQL user (called "postgres"). Make sure to choose a strong, unique password.
- After the installation is complete, start the PostgreSQL server:sudo systemctl start postgresql
- You can verify that the server is running by checking its status:sudo systemctl status postgresql
- To make sure the server starts automatically when the system boots up, enable it:sudo systemctl enable postgresql
- To log in to the PostgreSQL command line as the "postgres" user, use the following command:sudo -u postgres psql
That's it! You should now have PostgreSQL installed and running on your Ubuntu system.