Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 25, 2022 04:49 am GMT

Install and config PostgreSQL on Ubuntu Linux

First we need to install PostgreSQL
sudo apt get install postgresql postgresql-contrib

Now we check the path for PostgreSQL(for me it is version 12, it might be different for you)
ls /etc/postgresql/12/main/

This allows us to check all of the commands available to us
service postgresql

This will allow us to check the status
service postgresql status

This will log us in as the default user
sudo su postgres

Now if we run psql we will enter the postgresql cli.

From here, you can run \l to see the default databases.

You can also run \du to list all of the users.

To change the password of the default user 'postgres', run ALTER USER postgres WITH PASSWORD 'test123';

To create a new user:
CREATE USER nova_glow WITH PASSWORD 'test123';

Now if we want to give our new user "super" access...
ALTER USER nova_glow WITH SUPERUSER;

If You want to remove a user, simply do the following:
DROP USER user_2;

If you want to see all of the available commands for psql, you can simply run man psql in a new shell.

Note: It is recommended to install pgadmin from the software center.


Original Link: https://dev.to/anthonygilbertt/install-and-config-postgresql-on-ubuntu-linux-4djd

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To