Sie sind auf Seite 1von 4

Guide how to unlock HR account in ORACLE.

We will be doing most of the exercises with HR account. You need to unlock it first.
First you need to connect to ORACLE as super user (sys as sysdba), and move from container
database to pluggable database where the HR user is located inside. Then we will unlock the HR
account. You cannot connect to it by default.
1. Open windows Command prompt (Winkey + R, cmd).
2. sqlplus
3. login: sys as sysdba
4. password: the password when you installed ORACLE DB.

Go to next page:
Switching from container database to pluggable database

 First of all we need to see where we are located. Most probably we are inside the container
database

SQL> show con_name

CON_NAME

------------------------------

CDB$ROOT

 CDB$ROOT means that you are inside the container database.


 We need to see if the pluggable database “orclpdb” is existing (you might have missed it’s
creation during Oracle DB install). So let’s verify:

SQL> select name, con_id from v$pdbs;

NAME

--------------------------------------------------------------------------------

CON_ID

----------

PDB$SEED

ORCLPDB

 Most important here is for you to see that you have “orclpdb” database (if it is missing, contact
me, Viorel)
 Now it’s time to switch to the pluggable database orclpdb:

SQL> alter session set container=orclpdb;

Session altered.

You have now switched from container database to the pluggable database orclpdb
 We can confirm it with the following command:

SQL> show con_name

CON_NAME

------------------------------

ORCLPDB

 You have now switched to pluggable database “orclpdb”, where the HR account is located
 But this database might still be closed. You need to see it’s state
 A pluggable database might be open or closed depending on its state.
 Let’s verify what is the current state of the pluggable database orclpdb:

SQL> select name, open_mode from v$pdbs;

NAME

--------------------------------------------------------------------------------

OPEN_MODE

----------

ORCLPDB

READ WRITE

 Here the dabase is already opened, but if the last line states: MOUNTED, you need to open it:

SQL> alter pluggable database open;

Pluggable database altered.

 Success. A database contain users (often schema and user are synonyms), some of them are
locked however, like HR user
Unlocking HR account

 Let’s see if we have HR user in database, (it should usually be included):

SQL> select * from all_users where username = 'HR';

USERNAME

--------------------------------------------------------------------------------

USER_ID CREATED COM O INH

---------- --------- --- - ---

DEFAULT_COLLATION

--------------------------------------------------------------------------------

IMP ALL

--- ---

HR

107 11-SEP-19 NO N NO

USING_NLS_COMP

NO NO

 So the user is present! 😊


 Now we need to unlock it:

SQL> alter user hr identified by hr account unlock;

User altered.

 Finally you can connect to HR user using SQL developer.


 IMPORTANT:
 ONCE YOU reboot your pc, your pluggable database orclpdb is closed again ☹
 You need to do the following steps again:
o Connect to sys as sysdba
o SQL> alter session set container=orclpdb;
 SQL> alter pluggable database open; Just a minor inconvenience, but the pluggable database
orclpdb will not taking your memory resources when it is closed;

Das könnte Ihnen auch gefallen