ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

Linux操作系统用户以同名数据库用户身份免密码登录Oracle11g数据库

2020-04-28 19:03:26  阅读:260  来源: 互联网

标签:数据库 用户 appviewdb SQL PATH os fanxin01 Oracle11g


Linux操作系统用户以同名数据库用户身份免密码登录Oracle11g数据库  

注: os_authent_prefix是Oracle用来验证用户尝试连接到server时指定的一个前缀。oracle把该参数的值和操作系统账户名和密码连接起来。当需要连接的时候,Oracle 把带有前缀的操作系统用户名和数据库中Oracle的用户名进行比较。其缺省值为 'ops$',当数据库中存在用户 ops$test。那么在操作系统上以 test 用户登录成功后,键入sqlplus / ,登录用户将是 ops$test。也可将该参数设为空,这样可以消除给操作系统的账户添加任何的前缀。

  操作流程说明 第一步,配置数据库,更新 os_authent_prefix  参数的值为空(默认ops$) 第二步,建立 数据库用户 appviewdb 并授予连接数据库权限 第三步,建立linux操作系统用户 appviewdb 并配置相关环境变量,以便其能使用sqlplus命令连接数据库 第四步,测试操作系统用户 appviewdb连接数据的情况   1.数据库参数相关配置,并重启数据库让配置生效 1.1 更新数据库 os_authent_prefix参数值为空(默认ops$) [oracle@fanxin01 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Sun Apr 26 19:39:11 2020 Copyright (c) 1982, 2013, Oracle.  All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options   SQL> show parameter os_au; NAME                     TYPE     VALUE ------------------------------------ ----------- ------------------------------ os_authent_prefix             string     ops$ remote_os_authent             boolean     FALSE SQL> SQL> alter system set os_authent_prefix="" scope=spfile; alter system set os_authent_prefix="" scope=spfile                                    * ERROR at line 1: ORA-01741: illegal zero-length identifier SQL> alter system set os_authent_prefix='' scope=spfile; System altered. SQL> show parameter os_au; NAME                     TYPE     VALUE ------------------------------------ ----------- ------------------------------ os_authent_prefix             string     ops$ remote_os_authent             boolean     FALSE     1.2重启数据库让配置生效 ###重启数据库 [oracle@fanxin01 ~]$ srvctl stop database -d FXDB [oracle@fanxin01 ~]$ srvctl status database -d FXDB 实例 fxdb1 没有在 fanxin01 节点上运行 实例 fxdb2 没有在 fanxin02 节点上运行 [oracle@fanxin01 ~]$ srvctl start database -d FXDB [oracle@fanxin01 ~]$ srvctl status database -d FXDB 实例 fxdb1 正在节点 fanxin01 上运行 实例 fxdb2 正在节点 fanxin02 上运行   [oracle@fanxin01 ~]$ sqlplus / as sysdba SQL> show parameter os_au; NAME                     TYPE     VALUE ------------------------------------ ----------- ------------------------------ os_authent_prefix             string remote_os_authent             boolean     FALSE   2.创建数据库用户 appviewdb 并授予连接数据库的权限 SQL> create user appviewdb identified externally; User created.   SQL> grant connect,resource to appviewdb; Grant succeeded.   SQL> grant select on scott.emp to appviewdb; Grant succeeded.   SQL> set linesize 200; SQL> select * from scott.emp where rownum<2;      EMPNO ENAME      JOB           MGR HIREDATE        SAL       COMM     DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ----------       7788 SCOTT      ANALYST          7566 19-APR-87       3000            20   3.创建操作系统用户 appviewdb 并配置好环境变量 3.1 创建操作系统用户 appviewdb [root@fanxin01 ~]# useradd appviewdb [root@fanxin01 ~]# passwd appviewdb 更改用户 appviewdb 的密码 。 新的 密码: 无效的密码: 它基于字典单词 无效的密码: 过于简单 重新输入新的 密码: passwd: 所有的身份验证令牌已经成功更新。   3.2 配置操作系统用户 appviewdb 的环境变量,以使其能使用 sqlplus 命令连接数据库 [root@fanxin01 ~]# cat /home/oracle/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then     . ~/.bashrc fi     # User specific environment and startup programs     PATH=$PATH:$HOME/bin export PATH export ORACLE_SID=fxdb1 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib export PATH=$ORACLE_HOME/bin:$PATH stty erase ^h     [root@fanxin01 ~]# su - appviewdb [appviewdb@fanxin01 ~]$ cat ~/.bash_profile # .bash_profile     # Get the aliases and functions if [ -f ~/.bashrc ]; then     . ~/.bashrc fi     # User specific environment and startup programs PATH=$PATH:$HOME/bin export PATH export ORACLE_SID=fxdb1 export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib export PATH=$ORACLE_HOME/bin:$PATH stty erase ^h export PATH   4.测试操作系统用户 appviewdb 连接数据库情况 [appviewdb@fanxin01 ~]$ sqlplus /   SQL*Plus: Release 11.2.0.4.0 Production on Sun Apr 26 20:24:05 2020   Copyright (c) 1982, 2013, Oracle.  All rights reserved.   Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options     SQL> show user; USER is "APPVIEWDB"   SQL> set linesize 200; SQL> select * from scott.emp where rownum < 3;          EMPNO ENAME      JOB           MGR HIREDATE        SAL       COMM     DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ----------       7788 SCOTT      ANALYST          7566 19-APR-87       3000            20       7369 SMITH      CLERK          7902 17-DEC-80        800            20     至此,操作完毕,达到预期效果~!~记得点赞哦!

标签:数据库,用户,appviewdb,SQL,PATH,os,fanxin01,Oracle11g
来源: https://blog.csdn.net/tttt0611/article/details/105776725

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有