Oracle Database

Reset the Password for the Oracle Database User

Oracle Database is the most used relational database in the world providing many features for efficient data management. While working with Oracle, it is possible that people may forget their passwords, which can cause data access issues. To solve this problem, Oracle provides different commands that help the administrators in resetting the password.

This article will cover:

Reset the Password for the Oracle Database User

To reset the Oracle database user password, log in to the database as a user with “System Administrative Privileges”. To do that, type the following command:

SQLPLUS SYS/root1234 AS SYSDBA

In the above command, “root1234” is the password of the “SYS” user.

Output

The output showed that a connection had been created.

How to Reset Password for the Oracle Database User With ALTER Command?

To reset the password for the Oracle database user using the “ALTER” command, use the following syntax:

ALTER USER <username> IDENTIFIED BY <new_password>;

In this syntax, the “USER” keyword is for the username and the “IDENTIFIED BY” keyword is for the password.

Let’s reset the “C##LINUXHINT” user’s password by using the following query:

ALTER USER C##LINUXHINT IDENTIFIED BY linuxhint123;

In the above query, the “linuxhint123” is the password for the “C##LINUXHINT” user.

Output

The output showed that the password has been reset. Now, the user will be able to log in via the updated password.

Let’s log in as a “C##LINUXHINT” user with the new password. To do that, type the following command:

SQLPLUS C##LINUXHINT/linuxhint123

Output

The output showed that the user has been logged in with the new password.

How to Reset Password for Oracle Database User With PASSWORD Command?

To reset the password for the Oracle database user using the “PASSWORD” command, use the following syntax:

PASSWORD <username>

Let’s reset the password of the “C##LINUXHINT” user by typing the following query:

PASSWORD C##LINUXHINT

Executing the PASSWORD command will ask you to type the “New password”.

Output

The output showed that the password had been changed.

How to Force the Oracle Database User to Change/Modify Password in the Next Login?

While resetting the password, the administrator can force the Oracle database user to provide their own password at the next login. To do this, use the “PASSWORD EXPIRE” clause combined with the “ALTER” command.

The example code is given below:

ALTER USER C##LINUXHINT IDENTIFIED BY linuxhint935 PASSWORD EXPIRE;

In the above example, the “C##LINUXHINT” is a username, and the “linuxhint935” is the password.

Output

The output showed that the user had been altered.

To verify the working of the “EXPIRE” clause, log in with your new password:

SQLPLUS C##LINUXHINT/linuxhint935

In the above command, “linuxhint935” is the password.

Output

From the output, it is clear that the user was asked to change the password after the login.

How to Unlock the User’s Account While Resetting the Password in Oracle?

The user account can be unlocked by using the “ACCOUNT UNLOCK” statement while resetting the password with the “ALTER” command. The example is given below:

ALTER USER C##LINUXHINT IDENTIFIED BY linuxhint123 ACCOUNT UNLOCK;

In the above command, “linuxhint123” is the password.

Output

The output depicts that the password has been reset.

Conclusion

To reset the password for the Oracle database user, log in to the database with “System Administrative Privileges” using the “SQLPLUS” command. Then reset the password using the “ALTER” or “PASSWORD” command. The administrator can force the user to change the password in the next login and unlock the user account while resetting the password. This article has explained how to reset the password for the Oracle database user using practical examples.

About the author

Danish Ghafoor

I am a computer science graduate with a certification in cybersecurity. My passion for technology has led me to develop a deep understanding of the challenges and solutions in the field of information security. I am dedicated to staying up-to-date with the latest industry trends and technologies, and constantly seeking out new opportunities to expand my knowledge and skills.