banner



How To Set Postgres Password In Linux

It is necessary to secure your data and information from any intrusions, which tin can be done using passwords for your users. Passwords are used to protect your data from whatever mishap in the future then that no other user rather than you tin can enter into the organization. They are required when you are logged in or signed in to a particular system for authentication purposes.

In PostgreSQL, when you lot have once installed the setup, information technology will ask you to set a password for the default database, i.east., 'postgres'. Yous can likewise create your ain user later on in the PostgreSQL and prepare the countersign for that user. But what if there is a need to alter the countersign for managing a database or administration duties and there pop up a question in your mind, how and from where can you lot change the password? There is no need to worry because this commodity volition specifically focus on answering your question with elementary and different ways to change user passwords in PostgreSQL. This guide will help y'all to change user passwords and define each pace conspicuously for your ameliorate understanding.

Different Modes to Change User Password:

Yous tin can change user passwords through two different methods in PostgreSQL. In both methods, you lot can create and set a password and change information technology as well. These two methods are:

  • By using pgAdmin.
  • By using psql.

Steps to Modify Password Through pgAdmin:

When y'all open PostgreSQL, a screen that is displayed in front end of you lot something looks similar this:

A screenshot of a computer Description automatically generated with medium confidence

On the left side, a navigation carte can exist seen in which "Login/Group Roles" is divers. When clicking on that, a drop-past list appears.

A screenshot of a computer Description automatically generated with medium confidence

In this listing, all the usernames are stored that exist in a database with their defined and privileged roles along with them.

Permit's first create a username and set upward a password for that username, and then we will change the password. To create a username, click on "Login/Group Roles" and click on "create" a login or grouping role. Hither, we will create a login role in the database with desired roles.

A screenshot of a computer Description automatically generated with medium confidence

Later on clicking on the "Login/Group Roles" this will appear:

A screenshot of a computer Description automatically generated with medium confidence

In the name field, you can specify whatever name you lot desire. Then click on the "Definitions" and input the password for your username.
A screenshot of a computer Description automatically generated with medium confidence

In "Privileges" ascertain your user roles and salve your login user data in the end.
A screenshot of a computer Description automatically generated with medium confidence

Now, you lot have created a user, and you can simply alter the countersign by clicking on your username and and then "Properties" in the side navigation bar like this:

Graphical user interface, application Description automatically generated

The "Properties" will now open the aforementioned screen where y'all accept created the username for your login. Hither in the "Passwords" you lot can enter your new password and save it in the end.

A screenshot of a computer Description automatically generated with medium confidence

Graphical user interface, text, application Description automatically generated

In the "Passwords" field, re-enter your new countersign, and your password is changed for the username 'saeed_raza'.

Change Countersign Through psql:

In SQL crush (psql) you can also change the password using two ways:

  • Using Alter Function statements.
  • Using meta-commands.

Modify Password Using Change ROLE Statements:

The Alter ROLE statements are used to change the passwords of a user in PostgreSQL. Here is the basic syntax for using Alter Role statements in your database:

In the above argument, mention the username in place of 'username' of which you want to change the countersign. Then write the new password in place of 'new_password' to alter the password. The VALID UNTIL clause is optional; information technology is used to enter the time catamenia in which you want the password to be functional after the specified appointment or time the countersign will be expired.

Below is an illustration of altering the countersign of a username 'saeed_raza' with the new password as 'data'.

Change Part saeed_raza WITH PASSWORD 'information';

The Change Part command after the SQL statement ensures that the password is changed in the database.

Permit's encounter one more than example of changing the password which will be valid for the specific period that nosotros will assign:

ALTER ROLE saeed_raza WITH Countersign 'defined'

VALID UNTIL 'March 30, 2022' ;

I have changed the password from 'data' to 'defined' for the username 'saeed_raza' and mentioned the date till the countersign for this username would exist valid, which is 'March 30, 2022'. The password will be expired until this date, just if you don't put the VALID UNTIL clause in the argument, the password will be valid for the lifetime.

To ensure that the countersign would be valid until this date, run the post-obit command to verify:

This command volition display all lists of roles that are present in the databases with their attributes and username. The above control will show the following results:

Text Description automatically generated

In the above output, you can clearly encounter that in the Part proper name 'saeed_raza' the password is valid until the engagement 2022-03-xxx.

Change Password Using Meta Control:

In the above method, to change the countersign using Alter ROLE statements, we accept seen that the password is visible to the system, and information technology will also transfer that password to the server, which can be saved in the psql'southward statements history as well. You lot tin modify the password by keeping it condom and secure from the server log and its history in this method.

First, when starting the psql you must enter the username of which yous want to change the countersign:

Text Description automatically generated

I take entered the username 'saeed_raza' because I want to change the password of that user in PostgreSQL. At present, follow this simple syntax that will change the user's or default PostgreSQL password likewise past just using a meta-command:

postgres=# \password

Enter new password:

Enter it once more:

Text Description automatically generated

The password is at present changed for the user 'saeed_raza' by using this simple meta-command.

Conclusion:

In this guide, we have learned how nosotros tin change the user's password through pgAdmin and psql with unlike ways of psql likewise. All of the methods we used in this commodity were efficient and unproblematic, which you can implement on your system to finally answer your questions of how to change user passwords in PostgreSQL.

About the writer

Hello geeks! I am here to guide you almost your tech-related bug. My expertise revolves effectually Linux, Databases & Programming. Additionally, I am practicing law in Islamic republic of pakistan. Cheers to all of y'all.

How To Set Postgres Password In Linux,

Source: https://linuxhint.com/change-user-password-postgres/

Posted by: baileyexture56.blogspot.com

0 Response to "How To Set Postgres Password In Linux"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel