ORA-01017: invalid username/password; logon denied

I have a virtual machine with Oracle Database 19c installed. I downloaded this machine from Oracle.

{If you are interested, you can download it from the following url:



I started the virtual machine, login as oracle user, and ensured that the environment is set correctly:

Then, I tried to login to the database “/ as sysdba” using OS authentication as normal, but I got the following error:

Actually, the user oracle is the software owner and it is a member of the dba group:

If I tried to login using sys and sys password, it is working fine:

This is really very strange.

I created another user called ahmed, and assigned it to the dba group:

Now, let us try to login with ahmed, and then connect to the database using / as sysdba:

It worked fine, so, what may be the problem with the oracle user??????????????????????

Note that the database is a container database, its name is orclcdb, and it has one pluggable database called “ORCL”.

Also, there is an identified TNS entry in the tnsnames.ora file called ORCL, defined as follows:

After allot of research, I found the reason behind this issue.
There is environment variable called TWO_TASK, and it is set ORCL not orclcdb.
This parameter is actually overriding the ORACLE_SID setting.!!!

So, what is the meaning or usage of the TWO_TASK variable?

If you wanted to connect to a remote database or a to another database on the same machine via SQL*Net, you can set:

TWO_TASK = <tns connect string>

The setting of TWO_TASK overrides the ORACLE_SID when set. You will not connecting to a local database with two_task but rather using sqlnet to connect to a remote database.

So, in our case:
ORACLE_HOME was set to orclcdb, which is the container database, while:
TWO_TASK was set to ORCL, which is a pluggable database inside the orclcdb database.

So, when I issue “sqlplus / as sysdba”, I’m actually trying to connect to the pluggable database, not to the container database.

This also explains why it succeed to connect using username and password “sqlplus sys/oracle as sysdba”, because it is actually connecting to the pluggable database using database authentication not OS authentication in this case.

It looks like someone set this parameter to facilitate connecting to the pluggable database directly without specifying a connect string.

So, now to fix the original issue (ora-01017), I unset the TWO_TASK variable, and now I’m able to connect:



2 thoughts on “ORA-01017: invalid username/password; logon denied

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s