ORA-01031: insufficient privileges while connecting to database as sysdba

Example 1: sqlplus "/ as sysdba" showing ORA-01031 error from oracle user

[oracle@hostname ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Apr 19 10:59:10 2017

Copyright (c) 1982, 2011, Oracle. All rights reserved.

ERROR:

ORA-01031: insufficient privileges

Solution :

This issue can be for missing group or wrong group in $ORACLE_HOME/rdbms/lib/config.c

Case 1:

In my case the group mention in config.c was not created. After I have created the group it works fine.

[oracle@hostname ~]$ cat $ORACLE_HOME/rdbms/lib/config.c

#define SS_DBA_GRP "dba"

#define SS_OPER_GRP ""

#define SS_ASM_GRP ""

char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP, SS_ASM_GRP};

[oracle@hostname bin]$ id

uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1032(asmdba),1033(asmadmin) context=user_u:system_r:unconfined_t

[root@hostname ~]# usermod -a -G dba oracle

[oracle@hostname ~]$ id oracle

uid=1101(oracle) gid=1000(oinstall) groups=1031(dba),1032(asmdba),1033(asmadmin),1000(oinstall) context=user_u:system_r:unconfined_t

Case 2:

If you have wrong group set in $ORACLE_HOME/rdbms/lib/config.c file then in the following way you can fix it.

[oracle@hostname ~]$ cat $ORACLE_HOME/rdbms/lib/config.c

#define SS_DBA_GRP "oracle"

#define SS_OPER_GRP "oracle"

#define SS_ASM_GRP "oracle"

char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP, SS_ASM_GRP};

Typically the correct group for oracle user is: dba and not "oracle". Following way you can change it:

1. Edit $ORACLE_HOME/rdbms/lib/config.c and set the correct groups, for example

#define SS_DBA_GRP "dba"

#define SS_OPER_GRP "dba"

#define SS_ASM_GRP "dba"

char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP, SS_ASM_GRP};

2. [oracle@hostname ~]$ cd $ORACLE_HOME/rdbms/lib

[oracle@hostname lib]$$ mv config.o config.bck

3. [oracle@hostname ~]$ make -f ins_rdbms.mk ioracle

Example 2: sqlplus "/ as sysdba" showing ORA-01031 error from grid user

[grid@hostname ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Jul 3 13:22:23 2015

Copyright (c) 1982, 2011, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Automatic Storage Management option

ERROR:

ORA-01031: insufficient privileges

Solution:

[root@ hostname ~]# cat /etc/group |grep dba:

dba:x:101:

asmdba:x:1201:grid

Add grid user to dba group:

[root@producao ~]# vi /etc/group

dba:x:101:grid

[grid@ hostname ~]$ id

uid=1100(grid) gid=1000(oinstall) grupos=101(dba),1000(oinstall),1200(asmadmin),1201(asmdba),1202(asmoper)

[grid@ hostname ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Jul 3 13:28:39 2015

Copyright (c) 1982, 2011, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Automatic Storage Management option

SQL>