今天需要使用sys用戶處理問題,但是報錯上面ora-01031:insufficient privileges。
在網上有很多方法,這個是自己經過測試的方法步驟。
1:首先檢查文件sqlnet.ora文件是否設置正確(文件地址就是你oracle安裝的目錄)
- # sqlnet.ora Network Configuration File: /app/oracle/product/10.2.0/network/admin/sqlnet.ora
- # Generated by Oracle configuration tools.
- NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME)
- <span style="color:#FF0000;">SQLNET.AUTHENTICATION_SERVICES=(ALL)
- </span>
2:如果上面設置正確(為什么設置可以參考http://blog.csdn.net/huoyin/article/details/45544709)
然后用ssh等連接工具訪問Linux服務器這里注意了如果存在多個實例需要指定
登錄oracle
- su - oracle
指定實例
- export ORACLE_SID=***
3:需要檢查系統配置
登錄oracle
- sqlplus / as sysdba
查詢
- SQL> show parameter password
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- remote_login_passwordfile string EXCLUSIVE
- SQL>
2:檢查有哪些用戶
- SQL> select * from v$pwfile_users;
- USERNAME SYSDB SYSOP
- ------------------------------ ----- -----
- SYS TRUE TRUE
- SQL>
因為我已經操作過了現在顯示是有sys的,沒有設置的是空的
- SQL> grant sysdba to sys;
- grant sysdba to sys
- *
- ERROR at line 1:
- ORA-01994: GRANT failed: password file missing or disabled
3:現在添加文件退出oracle用戶
- SQL> exit
- Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
- With the Partitioning, OLAP and Data Mining options
- [oracle@dd ~]$
4:添加文件
執行添加加密的建立password文件
- [oracle@dd ~]$orapwd file=/app/oracle/product/10.2.0/dbs/orapwprice.ora password=111111 entries=10 force=y
因為是linux所以文件明是orapw+實例.ora
window是pwd+實例.ora
5:重啟服務,用sys登錄