I installed a XE PDB but I cannot seem to create a user that can connect through the command prompt so I can run scripts: '''
C:\> sqlplus sys as sysdba
SQL> alter session set container = xepdb1;
SQL> create user script_tester identified by Tester_8976 container=current;
SQL> grant create session to script_tester container=current;
SQL> exit
C:\> sqlplus script_tester/Tester_8976@xepdb1
Error:
ORA-01017: invalid credential or not authorized; logon denied
Help: https://docs.oracle.com/error-help/db/ora-01017
''' I can connet by sqldeveloper but not by sqlplus from the command prompt. What am I doing wrong? Thank you !
To me, xepdb1
looks suspicious. If you installed the database as I did - by accepting all defaults - try with pdb1
instead.
Here's how it goes in my database:
c:\temp>sqlplus sys as sysdba
SQL*Plus: Release 21.0.0.0.0 - Production on Sat Feb 22 20:05:25 2025
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 21c Express Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
SQL> alter session set container = xepdb1;
Session altered.
SQL> create user script_tester identified by tester container=current;
User created.
SQL> grant create session to script_tester container=current;
Grant succeeded.
SQL> connect script_tester/tester@pdb1 --> here
Connected.
SQL>
Why pdb1
? Because that's how it is named in TNSNAMES.ORA:
# 21cXE on my laptop
PDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = my_laptop)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XEPDB1)
)
)
Service name is xepdb1
, but database alias is pdb1
.
What should you do? Check your own TNSNAMES.ORA file.