---
title: "sqlplus as sysdba可以登录,但是用pl/sql用sys用户登录报ora-01017"
author: "崔志军"
date: "2014-06-26T21:38:20Z"
tags: []
categories: ["数据库"]
slug: "sqlplus-as-sysdba-pl-sql-sys-ora-01017"
draft: false
lastmod: "2014-06-26T21:38:20Z"
id: 2085786
url: "https://369836166.iteye.com/blog/2085786"
---

[remote\_login\_passwordfile参数](http://blog.chinaunix.net/uid-25909722-id-3395279.html) 2012-11-02 16:54:10

分类： Oracle

转自：[http://www.dbasky.com/oracle/remote\_login\_passwordfile\_sqlnet\_ora.html](http://www.dbasky.com/oracle/remote_login_passwordfile_sqlnet_ora.html)

今天复习的一个知识点：

**remote\_login\_passwordfile**，一直对这个参数的认识只是停留在它控制是否sys用户能在远程使用密码文件认证登录，对于他的值设置，适用情况没有更深的研究，今天就打算做一些小实验来探索他的使用。  
本次测试基于windows的oracle 10g，可能测试结果会有偏差。

首先阅读10g reference文档中的描述：

作用：这个参数控制oracle是否检查密码文件 取值范围：none,shared（默认） none：oracle会忽略任何密码文件，此时有权限的用户（比如sys)必须使用操作系统认证。 shared：一个或多个数据库可以使用密码文件，这时密码文件中可以包含sys和非sys用户 **exclusive****：这个参数10g中取消了，但为了向后兼容，你可以设置，与shared功能一样。** rac中多个实例应该有相同的值。

在oracle数据库没有启动之前，oracle内的用户是无法通过oracle来认证的，sys用户要启动oracle，就必须使用别的认证方式：一是密码文件认证，二是操作系统认证。

**操作系统认证**：通常要求该用户属于**本地**DBA组，然后通过操作系统认证登录到oracle，从而来启动数据库。  
**密码文件认证**：如果是远程以sys用户登录来启动数据库，那么只有通过密码文件认证来登录了。  
这个时候remote\_login\_passwordfile就来控制是否可以远程来登录。

1.remote\_login\_passwordfile = NONE

此时不能使用任何密码文件来登录数据库，只能在**本地**通过操作系统认证来起停数据库，远程sysdba登录是不被允许的，即使你$ORACLE\_HOME/dbs下有密码文件。这样类似在别的机器上使用sqlplus sys/oracle@orcl as sysdba语句的登录都会报错。此时，即使你在本地机器上OEM database control也是会报错的，提示无效的用户名密码，实际也是不能用密码文件验证身份。

2.remote\_login\_passwordfile = SHARED

此时可以在远程使用密码文件认证来登录数据库，如果本地没有密码文件，或者密码文件丢失，也是不能登录成功的，此时可以使用orapwd重新创建密码文件。remote\_login\_passwordfile = SHARED时，更改sys用户密码是不被允许的。同时授予除sys外的其他用户sysdba权限也是不允许的。此时可以通过密码文件在本机成功登录OEM database control。

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

SQL&gt; **show** parameter pass   

NAME                                 TYPE        VALUE   
*------------------------------------ ----------- ------------------------------*   
remote\_login\_passwordfile            string      SHARED   

SQL&gt; **select** * **from** v$pwfile\_users;   

USERNAME                       SYSDB SYSOP   
*------------------------------ ----- -----*   
SYS                             TRUE TRUE 

SQL&gt; **alter** user sys **identified** **by** oracle; 

**alter** user sys **identified** **by** oracle *   
ERROR at line 1: ORA-28046: Password **change** **for** SYS disallowed 

SQL&gt; **grant** sysdba **to** test; 

**grant** sysdba **to** test *   
ERROR at line 1: ORA-01999: password file cannot be updated **in** SHARED mode

windows系统中，shared模式下打开数据库的话不能删除pwd.ora文件，看来oralce会锁定这个文件给多个数据库使用。  
2.remote\_login\_passwordfile = EXCLUSIVE

oracle 10g文档中说exclusive与shared有相同的行为，可是我做的实验的结果并不是这样，可见oracle的文档也不能全信。11g中这个错误被修正了。

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

SQL&gt; **alter** system **set** remote\_login\_passwordfile=exclusive scope=spfile;   

System altered.   

SQL&gt; shutdown immediate; 

**Database** closed. **Database** dismounted. ORACLE instance shut down. 

SQL&gt; startup 

ORA-32004: obsolete **and**/**or** deprecated parameter(s) specified  
ORACLE instance started.    
Total System Global Area 264241152 bytes   
Fixed Size 1296160 bytes  
Variable Size 163580128 bytes   
**Database** Buffers 92274688 bytes   
Redo Buffers 7090176 bytes   
**Database** mounted. 

**Database** opened.   
SQL&gt;   
SQL&gt;   
SQL&gt; **show** parameter remote    
 NAME                                 TYPE VALUE  
 *------------------------------------ ----------- ------------------------*   
remote\_archive\_enable                 string true   
remote\_dependencies\_mode              string TIMESTAMP  
remote\_listener                       string   
remote\_login\_passwordfile             string EXCLUSIVE   
remote\_os\_authent                     **boolean** FALSE   
remote\_os\_roles                       **boolean** FALSE  
SQL&gt;   
SQL&gt;   
SQL&gt; **grant** sysdba **to** test;   **Grant** succeeded.     
SQL&gt;   
SQL&gt; **show** parameter compati     
NAME                                               TYPE         VALUE   
*------------------------------------               ----------- ------------------------*  
compatible string 10.2.0.3.0 plsql\_v2\_compatibility **boolean**      FALSE

当我又重新置会shared 模式时

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

SQL&gt; **alter** system **set** remote\_login\_passwordfile =shared scope=spfile   

System altered.   

SQL&gt; shutdown immediate; 

**Database** closed. **Database** dismounted. ORACLE instance shut down  
.   
SQL&gt; startup 

ORA-32004: obsolete **and**/**or** deprecated parameter(s) specified 

ORACLE instance started.     
Total System Global Area 264241152 bytes   
Fixed Size 1296160 bytes   
Variable Size 163580128 bytes   
**Database** Buffers 92274688 bytes   
Redo Buffers 7090176 bytes   
**Database** mounted.   
**Database** opened. 

SQL&gt; **show** parameter pass     
NAME                                 TYPE         VALUE  
*------------------------------------ ----------- ---------*   
remote\_login\_passwordfile            string       SHARED   

SQL&gt; **select** * **from** v$pwfile\_users;   

USERNAME                       SYSDB  SYSOP   
*------------------------------ -----  -----*   
SYS                            TRUE   TRUE   
TEST                           TRUE   FALSE

SQL&gt;  
SQL&gt; **grant** sysdba **to** test; 

**grant** sysdba **to** test * 

ERROR at line 1: ORA-01999: password file cannot be updated **in** SHARED mode 

SQL&gt; **revoke** sysdba **from** test;

**revoke** sysdba **from** test * 

ERROR at line 1: ORA-01999: password file cannot be updated **in** SHARED mode