How to Fix ORA-01045: User Lacks CREATE SESSION Privilege; Logon Denied in Oracle

Grant CREATE SESSION, or a role that includes it, so a new user can connect, with the error and fix run on a real database.

ORA-01045 means the username and password were correct, but the user is not allowed to connect. Logging on to an Oracle database needs the CREATE SESSION system privilege, granted directly or through a role. A newly created user has no privileges at all, so this error is typical right after CREATE USER. An administrator grants CREATE SESSION, or a role that includes it.

Reproduce the Error

A test user without any privilege:

Example:

drop user if exists demo_app cascade;
create user demo_app identified by "Demo_Pass_26";       -- no privileges yet

Example:

sqlplus -s -L demo_app/Demo_Pass_26@localhost:1521/FREEPDB1 <<'SQL'
select user from dual;
SQL

Output:

ERROR:
ORA-01045: Login denied. User DEMO_APP does not have CREATE SESSION privilege.

SP2-0751: Unable to connect to Oracle.  Exiting SQL*Plus

Fix: Grant CREATE SESSION

Example:

grant create session to demo_app;
select privilege from dba_sys_privs where grantee = 'DEMO_APP';

Output:

Grant succeeded.

PRIVILEGE
_________________
CREATE SESSION

Example:

sqlplus -s -L demo_app/Demo_Pass_26@localhost:1521/FREEPDB1 <<'SQL'
select user from dual;
SQL

Output:

USER
----------
DEMO_APP

Things to Know

  • DB_DEVELOPER_ROLE includes CREATE SESSION along with the usual privileges for developers.
  • Revoking CREATE SESSION, or the role that provides it, is a way to stop an account from connecting without locking it.

Related Guides

Conclusion

ORA-01045 means the user may not connect. Grant CREATE SESSION, or a role such as DB_DEVELOPER_ROLE that includes it, and grant further privileges only as the user needs them.

Vinish Kapoor
Vinish Kapoor

An Oracle ACE, author of four books on Oracle APEX, SQL and PL/SQL, and Oracle Forms, and a software developer building Oracle database applications since 2001.

guest

0 Comments
Oldest
Newest Most Voted