I'm completely new to Oracle database and trying to follow steps in the 2 day guide: https://docs.oracle.com/en/database/oracle/oracle-database/21/tdddg/two-day-developer-intro.html
I downloaded an installed the XE database. I am trying to install the HR sample:
https://docs.oracle.com/en/database/oracle/oracle-database/21/comsc/installing-sample-schemas.html#GUID-CB945E4C-D08A-4B26-A12D-3D6D688467EA
However, the script failed. I've tried to narrow down the issue.
I logged in using sqlplus:
>sqlplus "/as sysdba"
and then tried to create a user:
SQL*Plus: Release 18.0.0.0.0 - Production on Tue Mar 16 00:05:06 2021
Version 18.4.0.0.0
Copyright (c) 1982, 2018, Oracle. All rights reserved.
SQL>CREATE USER hr identified by password;
ORA-65096: invalid common user or role name
after this error, I read on another form to try the following:
SQL> alter session set container = XEPDB1;
Session altered.
after the above command, I can create the user:
SQL> create user hr identified by password;
User created.
I also a sent the command:
SQL>GRANT CREATE SESSION TO hr;
Grant succeeded.
But when I try below, I get an error:
SQL>connect hr/password
ERROR:
ORA-01017: invalid username/password; logon denied
Warning: You are no longer connected to ORACLE.
Any ideas? I don't know what I need to do to connect as the hr user.
I was able to connect as follows:
sqlplus hr/password#//localhost:1521/XEPDB1
Related
Oracle database 21c express edition on Windows 11.
My error
ORA-12154: TNS:could not resolve the connect identifier specified
My password is xxxxxa# . I see https://stackoverflow.com/a/67141887/3728901 How to enter password?
Update: Thank to Connor's answer. I catch
Microsoft Windows [Version 10.0.19044.1889]
(c) Microsoft Corporation. All rights reserved.
C:\Users\Administrator>sqlplus /nolog
SQL*Plus: Release 21.0.0.0.0 - Production on Thu Aug 25 10:21:18 2022
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
SQL> connect sys/"123456a#"#xe
ERROR:
ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
SQL>
Double quotes are your friend here
SQL> create user XXX identified by 123#456;
create user XXX identified by 123#456
*
ERROR at line 1:
ORA-00922: missing or invalid option
SQL> create user XXX identified by "123#456";
User created.
SQL> grant create session to xxx;
Grant succeeded.
SQL> connect xxx/123#456#db19_pdb1
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
Warning: You are no longer connected to ORACLE.
SQL> connect xxx/"123#456"#db19_pdb1 as sysdba
Connected.
sqlplus /nolog
connect sys/"123456a#"#xe as sysdba
SQL> alter session set "_ORACLE_SCRIPT"=true;
SQL> create user donhuvy identified by "123456a#";
SQL> grant create session to donhuvy;
SQL> connect donhuvy/"123456a#"#xe
Installed on CentOS 8.
Tried both
Oracle Database Express Edition (XE)
Enterprise Edition
from here https://www.oracle.com/database/technologies/oracle-database-software-downloads.html
ords.war taken from https://www.oracle.com/database/technologies/appdev/rest-data-services-downloads.html
Installation went well
java -jar ords.war install
https://docs.oracle.com/cd/E56351_01/doc.30/e58123/rest.htm#GUID-4F666968-86CF-44EC-9784-1DFCE88F908F
On the step where I must execute PL/SQL procedure I am getting
[oracle#oracle-ee-8gb ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 28 11:08:59 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> EXEC ords.enable_schema;
BEGIN ords.enable_schema; END;
*
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00201: identifier 'ORDS.ENABLE_SCHEMA' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Of course, first I tried with a newly created user - exactly for SODA purposes
CREATE USER JSONDB IDENTIFIED BY MyNewPassword;
GRANT CONNECT, RESOURCE TO JSONDB;
GRANT UNLIMITED TABLESPACE TO JSONDB;
GRANT CREATE SESSION TO JSONDB;
and logged as
sqlplus JSONDB/MyNewPassword#localhost/ORCLCDB
Also tried to do the same on official Docker images https://github.com/oracle/docker-images/tree/main/OracleDatabase - same issue.
Output when I activate REST with docker
# docker run --name ords --network dbnet -p 8888:8888 -e ORACLE_HOST=oracledb -e ORACLE_PORT=1521 -e ORACLE_SERVICE=ORCLPDB1 -e ORACLE_PWD=*** -e ORDS_PWD=*** -e CONTEXT_ROOT=ords -v /root/ords-config-data:/opt/oracle/ords/config/ords oracle/restdataservices:21.2.0
Requires to login with administrator privileges to verify Oracle REST Data Services schema.
Connecting to database user: SYS AS SYSDBA url: jdbc:oracle:thin:#//oracledb:1521/ORCLPDB1
Retrieving information.
Enter a number to select a feature to enable:
[1] SQL Developer Web (Enables all features)
[2] REST Enabled SQL
[3] Database API
[4] REST Enabled SQL and Database API
[5] None
Choose [1]:
2021-07-28T14:17:01.072Z INFO HTTP and HTTP/2 cleartext listening on host: localhost port: 8888
2021-07-28T14:17:01.173Z INFO The document root is serving static resources located in: /opt/oracle/ords/doc_root
2021-07-28T14:17:02.540Z INFO No pools configured yet
2021-07-28T14:17:04.115Z INFO Oracle REST Data Services initialized
Oracle REST Data Services version : 21.2.0.r1741826
Oracle REST Data Services server info: jetty/9.4.42.v20210604
Of course, it gives 404 because I can't make it to enable REST for the schema
# curl -i -X PUT http://localhost:8888/ords/jsondb/soda/latest/mycoll
HTTP/1.1 404 Not Found
Content-Type: application/problem+json
Content-Length: 336
{
"code": "NotFound",
"title": "Not Found",
"message": "The request could not be mapped to any database. Check the request URL is correct, and that URL to database mappings have been correctly configured",
"type": "tag:oracle.com,2020:error/NotFound",
"instance": "tag:oracle.com,2020:ecid/au4ymHSYbdm27PDCJ9KjsA"
}
Docker setup:
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f26a03a15512 oracle/restdataservices:21.2.0 "/bin/sh -c $ORDS_HO…" 4 minutes ago Up 4 minutes 0.0.0.0:8888->8888/tcp, :::8888->8888/tcp ords
6928780180b4 oracle-ee:latest "/bin/sh -c 'exec $O…" 51 minutes ago Up 51 minutes (healthy) 0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:5500->5500/tcp, :::5500->5500/tcp oracledb
Of course, I tried to install JDK locally and installing manually, not only using https://github.com/oracle/docker-images/tree/main/OracleRestDataServices
There's no option to even activate REST using SQL Developer
# java -jar ords.war install advanced
Specify the database connection type to use.
Enter number for [1] Basic [2] TNS [3] Custom URL [1]:1
Enter the name of the database server [localhost]:
Enter the database listen port [1521]:
Enter 1 to specify the database service name, or 2 to specify the database SID [1]:
Enter the database service name:ORCLPDB1
Enter 1 if you want to verify/install Oracle REST Data Services schema or 2 to skip this step [1]:
Enter the database password for ORDS_PUBLIC_USER:
Confirm password:
Requires to login with administrator privileges to verify Oracle REST Data Services schema.
Enter the administrator username:SYS AS SYSDBA
Enter the database password for SYS AS SYSDBA:
Confirm password:
Connecting to database user: SYS AS SYSDBA url: jdbc:oracle:thin:#//localhost:1521/ORCLPDB1
Retrieving information.
Enter the default tablespace for ORDS_METADATA [SYSAUX]:
Enter the temporary tablespace for ORDS_METADATA [TEMP]:
Enter the default tablespace for ORDS_PUBLIC_USER [SYSAUX]:
Enter the temporary tablespace for ORDS_PUBLIC_USER [TEMP]:
Enter 1 if you want to use PL/SQL Gateway or 2 to skip this step.
If using Oracle Application Express or migrating from mod_plsql then you must enter 1 [1]:2
Enter a number to select a feature to enable:
[1] SQL Developer Web (Enables all features)
[2] REST Enabled SQL
[3] Database API
[4] REST Enabled SQL and Database API
[5] None
Choose [1]:
2021-07-28T20:16:57.913Z INFO reloaded pools: []
Installing Oracle REST Data Services version 21.2.0.r1741826
... Log file written to /root/ords_install_core_2021-07-28_221658_00061.log
Warning: Nashorn engine is planned to be removed from a future JDK release
... Verified database prerequisites
... Created Oracle REST Data Services proxy user
... Created Oracle REST Data Services schema
... Granted privileges to Oracle REST Data Services
... Created Oracle REST Data Services database objects
... Log file written to /root/ords_install_datamodel_2021-07-28_221715_00056.log
... Log file written to /root/ords_install_apex_2021-07-28_221716_00329.log
Completed installation for Oracle REST Data Services version 21.2.0.r1741826. Elapsed time: 00:00:19.493
Enter 1 if you wish to start in standalone mode or 2 to exit [1]:2
advanced here is mandatory - then instead of selecting SID you must choose Service name and set pluggable database (PDB) - in case of Oracle DB XE it's XEPDB1, for Enterprise Edition - ORCLPDB1
that's how user should be created
$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 28 20:06:06 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL> ALTER SESSION SET CONTAINER=ORCLPDB1;
Session altered.
SQL> CREATE USER testuser1 IDENTIFIED BY MyNewPassword DEFAULT TABLESPACE users QUOTA UNLIMITED ON users;
User created.
SQL> GRANT CREATE SESSION, CREATE TABLE, CREATE PROCEDURE TO testuser1;
Grant succeeded.
SQL> GRANT CONNECT, RESOURCE TO testuser1;
Grant succeeded.
SQL> GRANT SODA_APP TO testuser1;
Grant succeeded.
SQL> quit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
that's how rest should be enabled for the schema
$ sqlplus /nolog
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 28 20:21:19 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
SQL> CONN testuser1/MyNewPassword#ORCLPDB1
Connected.
SQL> EXEC ords.enable_schema;
PL/SQL procedure successfully completed.
SQL> COMMIT;
Commit complete.
alternatively, you can setup SQL Developer in the way of setting Service name instead of SID - Rest Services menu item will become available.
e:\apex.5\apex_5.1\apex>sqlplus no/log
sql>conn sys as sysdba
ERROR:
ORA-01031: insufficient privileges
so i couldn't continue to the next step of installing Apex.
You should really post what you exactly did, and how Oracle responded.
This is what your code produces in reality:
c:\Temp>sqlplus no/log
SQL*Plus: Release 11.2.0.2.0 Production on Sub Srp 10 13:19:01 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
ERROR:
ORA-01017: invalid username/password; logon denied
That is, you're connecting to user named no whose password is log, and there's no such user (as Oracle responded). I presume you meant to use /nolog, which is something quite different.
Here's how it works on my database:
c:\Temp>sqlplus /nolog
SQL*Plus: Release 11.2.0.2.0 Production on Sub Srp 10 13:17:30 2021
Copyright (c) 1982, 2014, Oracle. All rights reserved.
SQL> conn sys as sysdba
Enter password:
Connected.
SQL>
As you can see, no problem in connecting to the database if I provide valid credentials. I have no idea what you did wrong, because, there are inconsistencies in what you say vs. what you show.
By the way, why installing Apex 5.1. I'd suggest the latest available version (21.1 at the moment).
SQL*Plus: Release 12.2.0.1.0 Production on Thu Jul 9 15:06:37 2020
Copyright (c) 1982, 2016, Oracle. All rights reserved.
SQL> conn sys#Databasename as sysdba
Enter password:
Connected to an idle instance.
SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup nomount;
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file 'C:\APP\ADMINISTRATOR\VIRTUAL\PRODUCT\12.2.0\DBHOME_1\DATABASE\INITdatabasename.ORA'
SQL>
If I go to C:\APP\ADMINISTRATOR\VIRTUAL\PRODUCT\12.2.0\DBHOME_1\DATABASE\ There is no file with this name INITdatabasename.ORA
After search I found that I should create a pfile from spfile.
SQL> create pfile from spfile;
create pfile from spfile
*
ERROR at line 1:
ORA-01565: error in identifying file '?=\DATABASE\SPFILE%ORACLE_SID%.ORA'
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 5) Access is denied.
SPfile is available in database folder. But is unable to open. Please help.
You can specify spfile and pfile locations:
create pfile='path_to_pfile' from spfile='path_to_spfile';
Maybe you could try to restore it from backups if you have any.
Bellow you have a good guide:
https://www.thegeekstuff.com/2014/11/oracle-rman-restore/
I just installed SQLPLUS via this Ubuntu documentation. What are the default login and password credentials? Following the documentation, I already tried sqlplus username/password#//dbhost:1521/SID I have investigated similar questions below, but none of the solutions have been successful for me.
https://askubuntu.com/questions/159939/how-to-install-sqlplus#
Oracle TNS: net service name is incorrecly specified
How come sqlplus not connecting?
I have tried testuser/password credentials
sqlplus64 username/password#//dbhost:1521/SID
SQL*Plus: Release 12.1.0.2.0 Production on Wed Oct 14 23:08:13 2015
Copyright (c) 1982, 2014, Oracle. All rights reserved.
ERROR:
ORA-12154: TNS:could not resolve the connect identifier specified
Enter user-name: testuser
Enter password:
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:
How do I login, I'm sorry the comments don't make sense to me, could someone please write out an example, should I be 1sqlpus 64 username/password#//dbhost:1521/` ?