Search code examples
oracledockeroracle-xeoracle18c

Cannot connect to the new user created on Oracle database 18 XE in Docker


I recently built an image of oracle database 18xe using this script and created a container with following command:

$docker run --name myxedb \
-d \
-p 51521:1521 \
-p 55500:5500 \
-e ORACLE_PWD=hr \
-e ORACLE_CHARACTERSET=AL32UTF8 \
oracle/database:18.4.0-xe

Right after that I logged in with following command:

$docker exec -it --user=oracle myxedb bash
$. oraenv
>XE
$sqlplus sys@XEPDB1 as sysdba

Then I created an user on the oracle database using the following query:

ALTER SESSION SET CONTAINER = XEPDB1;
CREATE USER hra IDENTIFIED BY hr;
GRANT CONNECT TO hra;

But when I go to sqldeveloper and try to connect the hra user, I get this error, though I can log in as sys.

P.S:I am using OpenSuse 15.1 leap and docker 19.03.5.


Solution

  • You created your user in the pluggable database (SERVICE_NAME=XEPDB1), but you are logging in to the container database (SID=XE). SYS exists in both. Change the service name in your SQL Developer connection.