[英]Connecting to Oracle XE edition with sqlplus but without password
Yes, I've seen https://dba.stackexchange.com/a/140147是的,我见过https://dba.stackexchange.com/a/140147
The command sqlplus / as sysdba
mentioned in this answer and elsewhere on the web still asks me for password on my installation:在这个答案和 web 的其他地方提到的命令
sqlplus / as sysdba
仍然要求我在安装时输入密码:
Oracle Linux 7.7
oracle-database-xe-21c-1.0-1.x86_64
However, that command still asks me for password:但是,该命令仍然要求我输入密码:
[root@localhost ~]# su - oracle
Last login: Fri Sep 2 09:01:34 EDT 2022 on pts/0
[oracle@localhost bin]$ export ORACLE_HOME=/opt/oracle/product/21c/dbhomeXE
[oracle@localhost bin]$ cd /opt/oracle/product/21c/dbhomeXE/bin/
[oracle@localhost bin]$ ./sqlplus / as sysdba
SQL*Plus: Release 21.0.0.0.0 - Production on Fri Sep 2 09:02:24 2022
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:
I don't really need any database in particular.我真的不需要任何数据库。 My job is gathering some meta information about Oracle installation such as version, configuration file, database files dir etc.
我的工作是收集有关 Oracle 安装的一些元信息,例如版本、配置文件、数据库文件目录等。
Yes, I can read some of the info from oracle system files on RedHat and similar (Oracle Linux is compiled from RH sources, it's very similar to RH).是的,我可以从 RedHat 上的 oracle 系统文件和类似文件中读取一些信息(Oracle Linux 是从 RH 源编译的,它与 RH 非常相似)。 Still, some info is only available in
sqlplus
.不过,某些信息仅在
sqlplus
中可用。
UPDATE :更新:
Regarding shell environment I've done as oracle
user is:关于 shell 环境,我作为
oracle
用户完成的是:
export ORACLE_HOME=/opt/oracle/product/21c/dbhomeXE
[oracle@localhost bin]$ ./oraenv
ORACLE_SID = [oracle] ?
ORACLE_HOME = [/home/oracle] ? /opt/oracle/product/21c/dbhomeXE
The Oracle base has been set to /opt/oracle
However, following command still asks me for password:但是,以下命令仍然要求我输入密码:
[oracle@localhost bin]$ ./sqlplus -l / as sysdba
SQL*Plus: Release 21.0.0.0.0 - Production on Fri Sep 2 09:24:55 2022
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
SP2-0751: Unable to connect to Oracle. Exiting SQL*Plus
[oracle@localhost bin]$
[oracle@localhost bin]$ ./sqlplus / as sysdba
SQL*Plus: Release 21.0.0.0.0 - Production on Fri Sep 2 09:24:59 2022
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:
The "Enter user-name:" prompt is appearing because the initial login attempt failed, with ORA-12162.由于初始登录尝试失败,出现“输入用户名:”提示,出现 ORA-12162。 By default it will try to log in up to three times, prompting for credentials each time - except the first time, since you provided the first set to try on the command line.
默认情况下,它最多会尝试登录 3 次,每次都提示输入凭据 - 第一次除外,因为您提供了第一个在命令行上尝试的设置。
If you do ./sqlplus -l / as sysdba
then it will only try to log in once, instead of reprompting on error (to slightly paraphrase the usage notes).如果您执行
./sqlplus -l / as sysdba
那么它只会尝试登录一次,而不是重新提示错误(稍微解释一下使用说明)。
But it will still get that ORA-12162 error the first time.但它仍然会在第一次出现 ORA-12162 错误。
Your environment isn't set up properly.您的环境设置不正确。 You've manually set
ORACLE_HOME
, but not any other Oracle-related environment variables ;您手动设置了
ORACLE_HOME
,但没有设置任何其他Oracle 相关的环境变量; specifically here ORACLE_SID
(or maybe TWO_TASK
to connect remotely).特别是这里
ORACLE_SID
(或者可能是TWO_TASK
远程连接)。 You probably want to set other things like PATH
properly too.您可能还想正确设置
PATH
等其他内容。
The Oracle home bin
directory includes an oraenv
script that you can source that ( rather than just executing it ) to set the environment up for a specific local DB, using Oracle 主
bin
目录包含一个oraenv
脚本,您可以获取该脚本(而不仅仅是执行它)来为特定的本地数据库设置环境,使用
. ${ORACLE_HOME}/bin/oraenv
or或者
source ${ORACLE_HOME}/bin/oraenv
... but you might prefer to set things manually. ...但您可能更喜欢手动设置。
I don't really need any database in particular.
我真的不需要任何数据库。 My job is gathering some meta information about Oracle installation such as version, configuration file, database files dir etc.
我的工作是收集有关 Oracle 安装的一些元信息,例如版本、配置文件、数据库文件目录等。
You already effectively know the database software version, 21c, from the ORACLE_HOME
path, but there is an oraversion
executable in the bin
dir that lets you get more detailed information about the version of the Oracle binaries in that home.您已经从
ORACLE_HOME
路径有效地知道了数据库软件版本 21c,但是bin
目录中有一个oraversion
可执行文件,可让您获得有关该主目录中 Oracle 二进制文件版本的更多详细信息。
The rest of the information is specific to a database.信息的 rest 特定于数据库。 You might be able to find a text
pfile
, or more likely a binary spfile
, but is you're using ASM those might not be on a normal local filesystem.您可能能够找到一个文本
pfile
,或者更可能是一个二进制spfile
,但是您使用的 ASM 可能不在正常的本地文件系统上。 really you do need to connect to the database to interrogate it for file and directory location etc.真的,你确实需要连接到数据库来询问它的文件和目录位置等。
(It's also possible that the database version could be slightly different to the binaries version - it shouldn't be really but I think it's possible mid-upgrade if some of the upgrade scripts haven't been run. I might be wrong though. But query v$version
anyway to be sure.) (数据库版本也可能与二进制版本略有不同 - 它不应该是真的,但我认为如果某些升级脚本尚未运行,则可能会在升级中进行。不过我可能是错的。但是无论如何查询
v$version
以确定。)
the goal is to detect software systems such as Oracle installed on all endpoints where the agent is working
目标是检测安装在代理工作的所有端点上的软件系统,例如 Oracle
If the server is acting as an Oracle database server then it should have an oratab
file, usually as /etc/oratab
or /var/opt/oracle/oratab
or similar - you might need to locate
it.如果服务器充当 Oracle 数据库服务器,那么它应该有一个
oratab
文件,通常是/etc/oratab
或/var/opt/oracle/oratab
或类似文件 - 您可能需要locate
它。
That lists all of the local databases in colon-delimited form, eg orcl:/opt/oracle/product/21c/dbhomeXE:Y
, with the first two elements being the ORACLE_SID
and ORACLE_HOME
values.这以冒号分隔的形式列出了所有本地数据库,例如
orcl:/opt/oracle/product/21c/dbhomeXE:Y
,前两个元素是ORACLE_SID
和ORACLE_HOME
值。 (The third is an auto-start flag). (第三个是自动启动标志)。 So you can parse that file to identify the Oracle home directory (or directories; there could be more than one), and the SID value(s) to pass to
oraenv
for each version and that you can attempt to log in to.因此,您可以解析该文件以识别 Oracle 主目录(或多个目录;可能有多个),以及为每个版本传递给
oraenv
并且您可以尝试登录的 SID 值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.