oracle-databasedockersqlplus

sqlplus myusername/mypassword@ORCL not working with Oracle on Docker


I am following this tutorial to run Oracle in a Docker image https://oralytics.com/2021/10/01/oracle-21c-xe-database-and-docker-setup/

I already have the image and now I should run

sqlplus system/SysPassword1@//localhost/XEPDB1

But this commands triggers a username and password ask (as on the image below), and when I try to put these information as:

it does not work with the following error

    SP2-0306: Invalid option.
Usage: CONN[ECT] [{logon|/|proxy} [AS {SYSDBA|SYSOPER|SYSASM|SYSBACKUP|SYSDG|SYSKM|SYSRAC}] [edition=value]]
where <logon> ::= <username>[/<password>][@<connect_identifier>]
      <proxy> ::= <proxyuser>[<username>][/<password>][@<connect_identifier>]
Enter user-name: system  
Enter password: 
ERROR:
    ORA-12162: TNS:net service name is incorrectly specified

SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus

Don't know what to do here. enter image description here


Solution

  • This isn't Docker (I never used it), but shows what to do (at least, I hope so).

    When entering username and password separately, you have to specify database along with username:

    c:\temp>sqlplus
    
    SQL*Plus: Release 21.0.0.0.0 - Production on Mon Apr 1 11:02:12 2024
    Version 21.3.0.0.0
    
    Copyright (c) 1982, 2021, Oracle.  All rights reserved.
    
    Enter user-name: scott@pdb1                                       --> this
    Enter password:
    Last Successful login time: Mon Apr 01 2024 09:38:48 +02:00
    
    Connected to:
    Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
    Version 21.3.0.0.0
    
    SQL>