Reset Oracle Password
This blog entry shows you how to reset the system
password for an Oracle Database. It uses a Linux image running Oracle Database 11g Express Edition. It assumes the student
user is the sudoer user.
After you sign on to the student
user account, you open a Terminal session and you should see the following:
[student@localhost python]$ |
The oracle
user account should be configured to prevent a login. So, you should use the su
command or sudo
command to open a terminal shell as the root
user.
[student@localhost python]$ sudo sh [sudo] password for student: |
As the root
user, you can login as the oracle user with the following command:
su - oracle |
and, you should see the following prompt. You can see the present working directory (pwd
) with the pwd command:
-bash-4.2$ pwd /u01/app/oracle |
You need to source the oracle_env.sh
shell file created by the installation of the Oracle Database during the installation. You have two approaches to source the environment file, the first approach is with a dot (.
), like
. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh |
or, this
source /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh |
The oracle_env.sh
file contains the following:
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe export ORACLE_SID=XE export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh` export PATH=$ORACLE_HOME/bin:$PATH |
Now, you can connect to the Oracle Database as the internal user with the following command:
sqlplus / as sysdba |
Once connected as the internal user, you can reset the system
user’s password to “cangetin
” with this command:
ALTER USER system IDENTIFIED BY cangetin; |
At this point, you can also stop and start the database. You stop the database with this command:
shutdown immediate |
You can then start the database with this command:
startup |
After setting the system
user password, sign out of SQL*Plus. Then, you can type two exits to return to the student
user account, like this:
-bash-4.2$ exit logout sh-4.2# exit exit [student@localhost python]$ |
As always, I hope this helps those who need to reset the system
password when they don’t know what it was to begin with.