PostgreSQL install on Ubuntu

Chinmay Roy
2 min readApr 25, 2023

--

Easy way to install PostgreSQL and Uses. To install PostgreSQL on Ubuntu, you can follow these steps:

PostgreSQL install on Ubuntu

Installation Steps:

  1. Open a terminal window on your Ubuntu machine.
  2. Update the package list by running the following command:
sudo apt-get update

3. Install PostgreSQL by running the following command:

sudo apt-get install postgresql

Additional, To install both the main PostgreSQL software and the contrib package on Ubuntu, you can use the following command:

sudo apt-get install postgresql postgresql-contrib

Usages Steps:

  1. Once the installation is complete, PostgreSQL will automatically create a user account named “postgres”. You can switch to this account by running the following command:
sudo -i -u postgres

2. You can then start the PostgreSQL command-line interface by running the following command:

psql

3. To create a new PostgreSQL user with administrative privileges, run the following command:

CREATE USER exampleuser WITH PASSWORD 'examplepassword';
ALTER USER exampleuser WITH SUPERUSER;

Replace “exampleuser” and “examplepassword” with your desired username and password.

4. To create a new PostgreSQL database, run the following command:

CREATE DATABASE exampledatabase;

Replace “exampledatabase” with your desired database name.

5. You can exit the PostgreSQL command-line interface by running the following command:

\q

Conclusion

That’s all! You now have PostgreSQL installed on your Ubuntu machine and can start using PostgreSQL for your applications. If you like this article then please share with your friends. If you have any comments then please let me know.

--

--

Chinmay Roy
Chinmay Roy

No responses yet