oracle本地验证,Oracle 本地验证和密码文件
實驗:
oracle服務器位于Linux操作系統,客戶端位于windows操作系統。
首先,查看remote_login_passwordfile參數值:
SYS@orcl 11-SEP-14>show parameter remote_login_passwordfile
NAME TYPE VALUE------------------------------------ ----------- ------------------------------
remote_login_passwordfile string EXCLUSIVE
找到$ORACLE_HOME/network/admin目錄下的sqlnet.ora,在文件末尾加上:
SQLNET.AUTHENTICATION_SERVICES=NONE
#Purpose:Use parameter SDP.PF_INET_SDP to specify the protocol family or# address family constantfor the SDP protocol onyour system.
#
#Supported since:11.0#
SQLNET.AUTHENTICATION_SERVICES=none
即使用密碼文件認證方式,那么如果我們在本地使用sqlplus "/as sysdba"就會提示錯誤信息:
[]$ sqlplus "/assysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 12 22:45:56 2014Copyright (c)1982, 2009, Oracle. Allrights reserved.
ERROR:
ORA-01031: insufficient privileges
此時我們必須使用sys用戶名和密碼才可以登錄:
[]$ sqlplus "sys/sys assysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 12 22:47:08 2014Copyright (c)1982, 2009, Oracle. Allrights reserved.
Connectedto:
OracleDatabase 11g Enterprise Edition Release 11.2.0.1.0 -ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options
進入sqlnet.ora把SQLNET.AUTHENTICATION_SERVICES=none改成“=all”,存盤退出。
再次使用sqlplus "/as sysdba"登錄的時候使用的就是本地認證:
[]$ sqlplus "/assysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Fri Sep 12 22:49:51 2014Copyright (c)1982, 2009, Oracle. Allrights reserved.
Connectedto:
OracleDatabase 11g Enterprise Edition Release 11.2.0.1.0 -ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing options
另外,我們可以使用orapwd這個工具來生成密碼文件。
首先看看orapwd的用法:
[]$ orapwd
Usage: orapwdfile= entries= force= ignorecase= nosysdba=
where
file - name of password file(required),
password- password for SYS will be prompted if notspecified at command line,
entries- maximum number of distinctDBA (optional),
force- whether to overwrite existing file(optional),
ignorecase- passwords are case-insensitive (optional),
nosysdba- whether to shut out the SYSDBA logon (optional Database Vault only).
There must be no spaces around the equal-to (=) character.
我們把位于$ORACLE_HOME/dbs目錄下的原orapworcl移到其它目錄。注意,remote_login_passwordfile=exclusive,且sqlnet.ora中SQLNET.AUTHENTICATION_SERVICES=none
在windows上的客戶端嘗試遠程oracle:
SQL> conn sys/sys@win assysdba
ERROR:
ORA-01031: insufficient privileges
現在我們使用orapwd來重建密碼文件:
[]$ orapwd file=$ORACLE_HOME/dbs/orapworcl password=sys entries=5
[]$ ls
hc_DBUA0.dat initorcl lkORCL peshm_DUMMY_0 spfileorcl.ora
hc_orcl.dat initorcl.ora orapworcl peshm_orcl_0
init.ora lkDUMMY peshm_DBUA0_0 snapcf_orcl.f
再次嘗試遠程連接oracle:
SQL> conn sys/sys@win assysdba
connected.
看看這個密碼文件的內容:
[]$ strings orapworclORACLE Remote Password file
INTERNAL
6A75B1BBE50E66AB
4DE42795E66117AE
在數據庫中創建一個新的用戶并授予sysdba的權限:
SYS@orcl 11-SEP-14>create user sunny identified bysunny;Usercreated.
SYS@orcl 11-SEP-14>grant sysdba tosunny;Grant succeeded.
再去看看orapworcl的內容,發現多了sunny這個用戶的信息:
[]$ strings orapworcl
ORACLE Remote PasswordfileINTERNAL
6A75B1BBE50E66AB
4DE42795E66117AE
SUNNY
53801465943A91BE
也可以通過動態性能視圖v$pwfile_users查看有哪些用戶是擁有sysdba權限的:
SYS@orcl 11-SEP-14>select * fromv$pwfile_users;
USERNAME SYSDB SYSOP SYSAS------------------------------ ----- ----- -----
SYS TRUE TRUE FALSE
SUNNY TRUE FALSE FALSE
總結
以上是生活随笔為你收集整理的oracle本地验证,Oracle 本地验证和密码文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 求一个好听的淘宝网店名字!
- 下一篇: 孕50天胎停育的症状