1、错误现象

SQL> grant sysdba to test;
grant sysdba to test
*
ERROR at line 1:
ORA-01994: GRANT failed: password file missing or disabled

SQL> ho oerr ora 01994
01994, 00000, "GRANT failed: password file missing or disabled"
// *Cause:  The operation failed either because the INIT.ORA parameter
//          REMOTE_LOGIN_PASSWORDFILE was set to NONE or else because the
//          password file was missing.
// *Action: Create the password file using the orapwd tool and set the
//          INIT.ORA parameter REMOTE_LOGIN_PASSWORDFILE to EXCLUSIVE.

2.根据提示分析解决

SQL> show parameter remote_login

NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
remote_login_passwordfile            string
EXCLUSIVE

SQL> ho ls $ORACLE_HOME/dbs/orapw*
/u01/app/oracle/product/11.1.0.6/dbs/orapworcl

果然没有当前数据库的密码文件。

3.使用orapwd重建当前数据库密码文件

首先查看orapwd的用法:

[oracle]$ orapwd
Usage: orapwd file=<fname> entries=<users> force=<y/n> ignorecase=<y/n> nosysdba=<y/n>

where
    file - name of password file (required),
    password - password for SYS will be prompted if not specified at command line,
    entries - maximum number of distinct DBA (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 dbs]$ orapwd file=/u01/app/oracle/product/11.1.0.6/dbs/orapwsales password=oracle entries=20   <---使用orapwd重建当前数据库密码文件

SQL> ho ls $ORACLE_HOME/dbs/orapw*
/u01/app/oracle/product/11.1.0.6/dbs/orapworcl  /u01/app/oracle/product/11.1.0.6/dbs/orapwsales  <--有了sales这个数据库的密码文件

SQL> grant sysdba to test; <--授权成功
Grant succeeded.
SQL> commit;  <--提交操作
Commit complete.

4.orapwd命令的详细解析及说明

[oracle]$ orapwd
Usage: orapwd file=<fname> entries=<users> force=<y/n> ignorecase=<y/n> nosysdba=<y/n>

where
    file - name of password file (required),
    password - password for SYS will be prompted if not specified at command line,
    entries - maximum number of distinct DBA (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.

例如:D:\oracle\ora92 \database>orapwd file=orcl.ora password=orclsys entries=2 其中参数entries的含义是表示口令文件中可以存放的最大用户数,对应于允许以SYSDBA/SYSOPER权限登录数据库的最大用户数,如果用户数 超过这个值只能重建口令文件,增大entries。

file后面可以指定口令文件的全路径和文件名,否则创建在当前目录下。

windows下oracle默认的位置是ora92/database目录,默认的文件名是 pwdSID.ora,对于别的文件名是不认的。linux下oracle默认的位置是$ORACLE_HOME/dbs目录,默认的文件名是 orapwSID,对于别的文件名是不认的。

(1)、为什么需要口令文件?

在数据库没有启动之前,数据库内建用户是无法通过数据库来验证身份的。口令文件中存放sysdba/sysoper
用户的用户名及口令,允许用户通过口令文件验证,在数据库未启动之前登陆,从而启动数据库。如果没有口令文件,在数据库未启动之前就只能通过操作系统认
证。
使用Rman,很多时候需要在nomount,mount等状态对数据库进行处理。所以通常要求sysdba权限如果属于本地DBA组,可以通过操作系统
认证登陆。如果是远程sysdba登陆,需要通过passwordfile认证。

(2)、口令文件损坏或者丢失怎么办?

口令文件就是sysdba/sysoper用户的唯一口令文件,丢了就进不来,不管数据库启动没有。连接报错...

SQL> connect sys/oracle@fzlgfm as sysdba 
ERROR: 
ORA-01031: insufficient privileges

只能用操作系统级权限验证登陆,即oracle/oracle登陆,然后orapwd重建口令文件: 
orapwd file=orcl.ora password=orclsys entries=2

Orapwd命令第二个参数是指定sys的密码,参数等于什么,sys密码以后就是什么。为什么要指定sys密码?
因为口令文件里面必须要有用户密码,否则怎么验证啊?但此时数据库如果没启动的话就根本取不到sys密码,所以只能强行指定了,启动后数据库里面sys的
密码会被改成此时指定的。另外重建口令文件的工作只能由系统验证用户完成,或者具有dba权限的用户也可以,其他用户执行orapwd命令都会失败。

(3)、如何把sysdba/sysoper用户加到口令文件中去?

再执行一遍grant sysdba/sysoper to 用户,oracle会自动在口令文件中增加一个条目,并且把密码copy过来。
察看口令文件内容的方法:
select * from v$pwfile_users;

SQL> grant sysdba to scott; 
Grant succeeded

SQL> select * from v$pwfile_users;

USERNAME SYSDBA SYSOPER 
--------------- ------- ------- 
SYS TRUE TRUE 
SCOTT TRUE FALSE

(4)、没有口令文件是否可以启动数据库?

可以。9i及以下mount过程中会报错,然后手动open就可以了。因为只要用本地验证用户照样可以做sysdba的事情,没有理由让数据库启动不了。10g已经不会报错了。

(5)、没有口令文件为什么是mount阶段报错而不是nomount阶段报错?

因为只有到了alter mount阶段才验证各种文件,nomount只读spfile/pfile创建进程。

(6)、修改sysdba/sysoper用户密码时,能否同步到口令文件?

可以同步。Alter user xxx identified by yyy 
所有密码忘记都没关系,但至少要记住sys用户密码。

(7)、spfile/pfile中remote_login_passwordfile是干嘛用的?

三种设定模式:可以通过show parameter pass命令查看当前模式

remote_login_passwordfile = EXCLUSIVE,则一个实例专用;

remote_login_passwordfile = SHARE则可以多个实例共享(用于OPS/RAC环境);

remote_login_passwordfile = NONE则不启用口令文件,此时任何sysdba/sysoper都无法连接进来。

remote_login_passwordfile = shared 我们看一下Oracle9i文档中的说明:
More than one database can use a password file. However, the only user recognized by the password file is SYS. 

思是说多个数据库可以共享一个口令文件,但是只可以识别一个用户:SYS。在用SPFILE的情况
下,remote_login_passwordfile参数怎么改呢?SPFILE是不可以强行编辑的,否则数据库不认的。用alter system
set remote_login_passwordfile=none scope=spfile。

改成NONE以后怎么改回来呢?

用os级认证登陆,然后alter system set remote_login_passwordfile=none scope=spfile,或者直接create spfile from pfile;

remote_login_passwordfile='none'意味着禁用口令文件,有也不能用。等于可以
disable所有sysdba/sysoper,此时只能用oracle/oracle用户来启动和关闭数据库,也就是只有os认证,没有口令文件认
证,这就是此参数的意义-口令文件验证的开关。

(8)、sqlnet.ora中SQLNET.AUTHENTICATION_SERVICES=(NTS/NONE)有什么用?

NTS=NT Security 即采用OS优先认证登陆,NONE为不可以,必须采用usr/pwd as
sysdba/sysoper
登陆。这里是操作系统级验证的开关。如果SQLNET.AUTHENTICATION_SERVICES=(NONE)并且
remote_login_passwordfile='none',即两个开关都关闭,那么神仙也进不了数据库,hoho我指的是
sysdba/sysoper用户,普通用户可以照常使用的。当然,有物理权限的人也除外,即你可以物理地打开这台计算机操作。

总结一下,ORACLE有两种方式可以认证sysdba/sysoper用户:操作系统级认证-dba权限组(linux
/unix)和ORA_DBA组(win);口令文件认证。
两种方式有各自的开关:sqlnet.ora中AUTHENTICATION_SERVICES参数;spfile/pfile中
remote_login_passwordfile参数。并且这两个开关互不矛盾,可以同时打开同时关闭或者只开一个。

参考文档:

http://blog.itpub.net/28716724/viewspace-756259/

http://www.cnblogs.com/51linux/archive/2013/06/08/3125788.html

ORA-01994: GRANT failed: password file missing or disabled的更多相关文章

  1. windows下安装pywin32报错:close failed in file object destructor:sys.excepthook is missing lost sys.stderr

    今晚要写搜索引擎作业,搭scrapy环境,遇到了下面问题: windows下安装pywin32报错:close failed in file object destructor:sys.excepth ...

  2. ORA-19563: header validation failed for file

    在测试服务器还原数据库时遇到了ORA-19563错误.如下所示 RMAN-00571: ======================================================== ...

  3. mysql 异常宕机 ..InnoDB: Database page corruption on disk or a failed,,InnoDB: file read of page 8.

    mysql 测试环境异常宕机 系统:\nKylin 3.3 mysql版本:5.6.15--yum安装,麒麟提供的yum源数据库版本 error日志 181218 09:38:52 mysqld_sa ...

  4. ADT开发AndroidManifest.xml file missing错误

    一个错误“AndroidManifest.xml file missing”但helloworld目录下有此文件,几番google仍没能解决.想起曾经在网络上看到的一个修复project的办法,抱着死 ...

  5. LR连接oracle时出现:SQLState=28000[Oracle][ODBC][Ora]ORA-01017:invalid username/password;logon denied

    出现的现象:

  6. django rest framework csrf failed csrf token missing or incorrect

    django rest framework csrf failed csrf token missing or incorrect REST_FRAMEWORK = { 'DEFAULT_AUTHEN ...

  7. 安卓(android)建立项目时失败,出现Android Manifest.xml file missing几种解决方法?(总结中)

    安卓(android)建立项目时失败.出现AndroidManifest.xml file missing几种解决方法?(总结中) Eclipse新建项目.遇到这种问题.注意例如以下: 1.文件名称最 ...

  8. AndroidManifest.xml file missing 解决方案

    如果在导入一个项目到ECLIPSE里时,不要把项目文件放到workspace里面,放到别处再导,否则可能会提示这个错误:AndroidManifest.xml file missing,顺便导入的方式 ...

  9. Ceph osd启动报错osd init failed (36) File name too long

    在Ceph的osd节点上,启动osd进程失败,查看其日志/var/log/ceph/ceph-osd.{osd-index}.log日志,报错如下: 2017-02-14 16:26:13.55853 ...

随机推荐

  1. 制作jar文件

    一.制作可运行jar文件 使用java的swing.awt制作了一个简单的界面交互模块.程序打成jar包后,能双击运行,制作过程: 1.eclipse →properties →Export,选择ja ...

  2. 神秘的ApplicationPoolIdentity再也不用妈妈担心程序池安全了

    在IIS 7和IIS 7.5中,我们可以为应用程序池设置一个特殊的Identity(用户标识):ApplicationPoolIdentity. 那么这个标识到底是什么意思?它是具体什么身份呢?这一讲 ...

  3. 谨慎能捕千秋蝉(二)——CSRF

    CSRF(Cross Site Request Forgery)跨站点请求伪造. CSRF的本质是当重要操作的参数都能被攻击者预测到,才能成功伪造请求. 一.场景演示 下图是一个伪造请求的场景,按顺序 ...

  4. Swift 2.0 字符串学习笔记(建议掌握OC字符串知识的翻阅)

    自己公司开现在使用OC语言在写,但Swift似乎是苹果更推荐使用的开发语言,估计也是未来开发的趋势,自己以前有接触swift,但又由于公司的项目赶,也没有时间去好好地学习这款开发语言.现在年底了,项目 ...

  5. html5_canvas初学

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 【中文分词】结构化感知器SP

    结构化感知器(Structured Perceptron, SP)是由Collins [1]在EMNLP'02上提出来的,用于解决序列标注的问题:中文分词工具THULAC.LTP所采用的理论模型便是基 ...

  7. win8 wifi开关显示关闭,且设置里面wifi开关显示灰色的解决办法

    只要从华硕官网下载驱动,电源管理驱动,安装下面显示的几个软件即可,然后重启电脑,即可看见wifi热点,另外设置里面的wifi开关也将显示正常(刚开始安装了个驱动人生根本没用,最后在华硕官网下载了个电源 ...

  8. 归纳篇(一)CSS的position定位和float浮动

    近期会更新一系列博客,对基础知识再度做个巩固和梳理. 一.position定位 (一):position的属性 1.absolute:生成绝对定位的元素,相对于最近一级定位不是static的父元素来进 ...

  9. 记一个Java错误 1 -- Unsupported major.minor version 52.0

    今天打开ADT eclipse 准备调试上周的安卓项目, 发现总是报错 如图: 百度了一下说是 jdk版本过低的问题  (低版本的jre运行高版本project) 于是就修改了一下 window - ...

  10. SpringBoot + SwaggerUI

    后台写接口,由于要提供接口文档给前台使用,所有研究了一下swagger,看到网上有篇文章写得不错,就直接拿过来了. swagger用于定义API文档. 好处: 前后端分离开发 API文档非常明确 测试 ...