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.
