Changing a user's password
Changing a user's password is easy. You will practice it by changing passwords for several users in this recipe.
Getting ready
To complete this recipe, you'll need an existing user who has alter user
privilege (you may use OS-authenticated user who has the DBA role) and other existing users (for example, jessica
and tom
).
How to do it...
- Connect to the database as a user who has
alter user
privilege:$ sqlplus /
- Change the password for user
jessica
:SQL> password jessica;
- Enter a new password (for example,
oracle_2
) on a command line (note that typing will not be visible in the command line):New password:
- Retype the new password (for example,
oracle_2
) on the command line (note that typing will not be visible in the command line):Retype new password:
- Connect to the database as any user (for example,
tom
, to change their own password):$ sqlplus tom/"Qax7UnP!123*"
- Change the password using the following code:
SQL> password
- Enter the old password (for example,
Qax7UnP!123*
) on the command line (note that typing will not be visible on the command line):Old password:
- Enter the new password (for example,
oracle_123
) on the command line (note that typing will not be visible on the command line):New password:
- Retype the new password (for example,
oracle_123
) on the command line (note that typing will not be visible on the command line):Retype new password:
How it works...
In step 1, you used OS authentication to connect to the database.
In steps 2 through 4, a privileged user changed jessica's password, where in steps 6 through 9, the user tom
changed his own password.
There's more...
There is another way to change the user's password using the alter user
statement as follows:
SQL> alter user jessica identified by oracle_2;
Tip
This approach is not recommended because password remains in the command-line history.
See also
- Creating and using OS-authenticated users