增加sudo用户访问oracle

时间:2022-05-09 04:01:49

增加zgy用户可以访问数据库
[[email protected] ~]# useradd zgy
--设置密码
[[email protected] ~]# passwd zgy
--设置组
[[email protected] ~]# usermod -G oinstall,dba zgy
--环境变量
[[email protected] ~]# cp ~oracle/.bash_profile ~zgy/.bash_profile 
--yes
--生效
[[email protected] ~]# source ~zgy/.bash_profile

[[email protected] ~]# su - zgy
[[email protected] ~]$ sqlplus / as sysdba 
...
--如下增加oracle,zgy两个用户
sudo vi /etc/sudoers

## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
zgy ALL=(ALL) ALL  --这个给的权限比较大些

[[email protected] ~]$ sql

SQL*Plus: Release 11.2.0.3.0 Production on Wed Dec 18 15:04:19 2019
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 Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SELECT STATUS FROM GV$INSTANCE ;

STATUS
------------------------------------
OPEN

Elapsed: 00:00:00.00