普通用戶:
數據庫審覈:
sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Wed May 2 03:52:20 2018 Copyright (c) 1982, 2009, Oracle. All rights reserved. Enter user-name: oracle Enter password: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options ORACLE@ sundb>
系統審覈:
在Linux系統root用戶下創建測試用戶
useradd -u 501 -g oinstall -G dba,oper,asmdba,asmadmin oracle
查看創建後結果
id test
uid=503(test) gid=501(oinstall) groups=501(oinstall),502(dba),503(oper),504(asmadmin),505(asmdba)
以dba身份登錄oracle開啓操作系統認證
sqlplus / as sysdba
查看認證前綴
select value from v$parameter where name = 'os_authent_prefix';
創建數據庫用戶並授權
create user ops$test identified externally;
User created.
Elapsed: 00:00:00.58grant create session to ops$test;
su - test
vi ./.bash_profile
添加以下內容
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
source ~/.bashrc
重新以test用戶測試登錄
[test@RHEL6 ~]$ /u01/app/oracle/product/11.2.0/db_1/bin/sqlplus /
SQL> show user
USER is "OPS$TEST"
可以修改文件打開操作系統審覈機制,但是由於oracle系統默認是打開操作系統認證的,所以也可以不修改以下文件
vi $ORACLE_HOME/network/admin/sqlnet.ora
將其中的SQLNET.AUTHENTICATION_SERVICES值改爲all
sqlnet.authentication_services=all
超級用戶:
系統審覈:
超級用戶的系統審覈必須在連接時帶有角色的描述conn / as sysdba
口令文件審覈:由於系統審覈級別要高於口令文件審覈,所以需要先將系統審覈關掉
先將oracle用戶移出dba組,在root用戶下執行
gpasswd -d oracle dba
Removing user oracle from group dba
返回oracle用戶登錄
su - oracle
sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed May 2 05:43:52 2018 Copyright (c) 1982, 2009, Oracle. All rights reserved. ERROR: ORA-01031: insufficient privileges
這時用操作系統認證時就會報錯了
SQL*Plus: Release 11.2.0.1.0 Production on Wed May 2 05:43:52 2018 Copyright (c) 1982, 2009, Oracle. All rights reserved. ERROR: ORA-01031: insufficient privileges
可以用超級用戶的用戶名密碼進行連接
sqlplus sys/dba as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed May 2 05:46:02 2018 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options