“ORA-01017: invalid username/password” : Why is that

oracleoracle-11g-r2sqlplus

What is the difference between the two :

SQLPLUS / AS SYSDBA

and

SQLPLUS
Enter user-name: SYSDBA
Enter password:

If I use the first command I get connected and see the prompt SQL> but upon using the second command I always get ORA-01017: invalid username/password; logon denied , when I enter the correct password. Why is this ?

Also how do I get connected as the SYSDBA using the first command , when I didn't enter any password.

I am using Oracle Database 11g Express Edition Release 11.2.0.2.0

Best Answer

SYSDBA is a role. When you connect using that role you're effectively connecting as the user SYS (say show user in SQL*Plus). As @A.B.Cade already said you're using external authentication (OS in this case), but if you want to connect remotely over network you're required to provide username and password (unless account is configured to use remote OS authentication), e. g. sqlplus sys/password@orcl as sysdba.

You may also grant other users the SYSDBA privilege:

sql> GRANT SYSDBA to SCOTT;

This way user SCOTT is able to connect to database with SYS privileges:

[spongebob@example]$ echo "show user" | sqlplus -S scott/password as sysdba
USER is "SYS"