您的位置:首页 > 博客中心 > 数据库 >

Oracle操作系统身份验证

时间:2022-03-14 04:49

此技术使用与操作系统用户同样的名称创建Oracle用户,但前面加上了os_authent_prefix参数指定的字符串,默认为ops$,下面我们来看看官档对该参数的说明:

OS_AUTHENT_preFIX specifies a prefix that Oracle uses to authenticate users attempting to connect to the server. Oracle concatenates the value of this parameter to the beginning of the user‘s operating system account name. When a connection request is attempted, Oracle compares the prefixed username with Oracle usernames in the database.

The default value of this parameter is OPS$ for backward compatibility with previous versions. However, you might prefer to set the prefix value to "" (a null string), thereby eliminating the addition of any prefix to operating system account names.

可见,用ops$只是为了向前兼容。

下面,我们来实验一下。

一、创建操作系统用户

     [root@node1 ~]# useradd test

二、创建Oracle用户并授予相应的权限

     SQL> create user ops$test identified externally;

     SQL> grant create session to ops$test;

三、用test用户登录数据库

[test@node1 ~]$ /u01/app/oracle/product/11.2.0.4/db_1/bin/sqlplus /
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory

    报以上错误,根据提示,我们为ORACLE_HOME设置响应的值

    在/home/test/.bash_profile中添加如下值:   

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1

    重新用test用户登录数据库

[test@node1 ~]$ /u01/app/oracle/product/11.2.0.4/db_1/bin/sqlplus /

SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 10 01:14:53 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

ERROR:
ORA-12162: TNS:net service name is incorrectly specified


Enter user-name: 

    又报TNS:net service name is incorrectly specified错误。

    怀疑没有指定响应的SID,在/home/test/.bash_profile中添加如下值:

export ORACLE_SID=orcl

    重新用test用户登录    

[test@node1 ~]$ /u01/app/oracle/product/11.2.0.4/db_1/bin/sqlplus /
SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 10 01:18:22 2015
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
SQL> show user
USER is "OPS$TEST"

    终于成功登录!

 

    

 

热门排行

今日推荐

热门手游