How to Unlock the HR User in XEPDB1

If you’re encountering an account locked error for the HR user in Oracle’s XEPDB1 pluggable database (PDB), follow these steps to unlock the account. This guide assumes you have administrative access to the Oracle database.

Step 1: List All PDBs

First, ensure you’re targeting the correct PDB by listing all available PDBs. Connect to the root container as an admin:

sqlplus sys as sysdba

Then, list all PDBs:

SHOW PDBS;

Step 2: Connect to XEPDB1

Once you’ve confirmed XEPDB1 is the correct PDB, switch to it:

ALTER SESSION SET CONTAINER = XEPDB1;

Step 3: Unlock the HR User

With your session set to XEPDB1, unlock the HR user:

ALTER USER HR ACCOUNT UNLOCK;

This will unlock the HR user in the XEPDB1 database, allowing you to log in using the HR credentials.

The complete session should look something like this:

PS …\ClassFiles\setup> sqlplus sys as sysdba

SQL*Plus: Release 21.0.0.0.0 - Production on Wed Apr 10 05:58:10 2024
Version 21.3.0.0.0

Copyright (c) 1982, 2021, Oracle.  All rights reserved.

Enter password:

Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0

SQL> SHOW PDBS;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 XEPDB1                         READ WRITE NO
SQL> ALTER SESSION SET CONTAINER = XEPDB1;

Session altered.

SQL> ALTER USER HR ACCOUNT UNLOCK;

User altered.

SQL>

Written by Nat Dunn. Follow Nat on Twitter.


Related Articles

  1. How to Unlock the HR User in XEPDB1 (this article)
  2. Oracle Live SQL Instructions
  3. Getting Oracle’s HR Schema
  4. How to Install Oracle Express Edition and SQL Developer
  5. Oracle’s Demo HR Schema
  6. How to choose between a procedure and a function in PL/SQL