1

I have the Oracle Database App Development VM (12c) and am trying to create a new container. Specifically:

conn / as sysdba
create pluggable database pdborcl admin user system identified by oracle FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb1/pdbseed/', '/u01/app/oracle/oradata/cdb1/pdb2'');

However, I cannot connect to the root container. The above conn spits out:

  URL           = jdbc:oracle:oci8:@(DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = orcl)    )  )
  Error Message = ORA-01017: invalid username/password; logon denied
  USER          = 
  URL           = jdbc:oracle:thin:@(DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))    (CONNECT_DATA =      (SERVER = DEDICATED)      (SERVICE_NAME = orcl)    )  )
  Error Message = ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.

And sqlplus / as sysdba returns:

ERROR:
ORA-01017: invalid username/password; logon denied

Logging in with sqlplus system as sysdba logs into the connection ORCL.

2 Answers 2

1

The reason for sqlplus / as sysdba not working is:

[oracle@localhost ~]$ grep -i two_task .bashrc
if test "m$DONOTSETTWO_TASK" = "m"
        export TWO_TASK=ORCL
[oracle@localhost ~]$ grep -i two_task .bashrc -A 1
if test "m$DONOTSETTWO_TASK" = "m"
        then
        export TWO_TASK=ORCL
        fi
[oracle@localhost ~]$ echo $TWO_TASK 
ORCL

SQL*Plus connections automatically connect to the TNS alias defined in the TWO_TASK environment variable. When it is set, sqlplus / as sysdba does not work.

It is like trying this (will not work):

sqlplus /@ORCL as sysdba

To "fix" this:

[oracle@localhost ~]$ unset TWO_TASK
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri May 11 15:20:59 2018

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> 

You can not connect to a PDB directly with SQL*Plus, you need to use a TNS alias or EZCONNECT. Setting TWO_TASK takes care of this, so you can login with for example sqlplus hr/hr directly to the PDB, without manually specifying its address.

I guess Oracle just wanted to make simple to connect to the ORCL PDB - instead of actually explaining how things work.

6
  • Oh man, that's crazy. Thank you! I found a similar answer elsewhere but was looking in .bash_profile where the variable obviously wasn't being set.
    – Druckles
    Commented May 14, 2018 at 7:55
  • Do you know why conn / as sysdba from within the sqlcl doesn't work?
    – Druckles
    Commented May 14, 2018 at 8:01
  • @Druckles Same reason. If you start sqlcl with the icon on the desktop, that starts a new terminal with TWO_TASK set. If you use unset TWO_TASK and sql / as sysdba in a terminal, you can log in. Commented May 14, 2018 at 8:15
  • Yeah, I assumed that, but how can I set it up to connect to a different container or even ask? I tried commenting out the set in the .bashrc, even changing it to something else (PDBORCL) to no effect. This isn't so important, just more out of interest. And sqlplus called from the command line has terrible input support. Cursor keys are not captured correctly for instance.
    – Druckles
    Commented May 14, 2018 at 9:06
  • @Druckles Comment the lines related to TWO_TASK in .bashrc. Log out from the desktop session, log in again, and you are good to go. Commented May 14, 2018 at 9:09
1

ALL of the passwords are 'oracle'

That includes: OS: root OS: oracle Database: SYS Database: SYSTEM Database: HR

oracle@vbgeneric ~]$ sqlplus sys as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri May 11 11:43:25 2018

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

Enter password: 

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> 

However, you're running into something different.

And it's discussed here.

Using TWO_TASK. A third way is by defining the TWO_TASK operating system variable to point to the PDB you want to connect to:

[oracle@prosrv1 schema]$ export TWO_TASK=PDB1

And, then you can connect as usual without giving a connect string:

[oracle@prosrv1 schema]$ sqlplus system/oracle

I prefer this last approach because it simulates a database connection prior to introduction of the PDB. If you connect to a specific PDB the majority of the time, all you have to do is to set this variable in the shell initialization file (e.g. .profile in case of bourne shell) of the user so that the variable is automatically set when you log in. If you need to know which PDB you are connected right now in SQL*Plus, just use the following command: To show which container (or, the PDB) you are connected to:

SQL> show con_id
CON_ID
------------------------------
5

SQL> show con_name
CON_NAME
------------------------------
PDB1
3
  • Sorry, this doesn't answer the question; I know what the passwords are.
    – Druckles
    Commented May 14, 2018 at 7:52
  • I didn't see the 2md line where you created the pdb, I'll delete my answer with my apologies Commented May 14, 2018 at 9:59
  • Can't delete so I'll fix the answer Commented May 14, 2018 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.