显示页面 修订记录 反向链接 页面重命名 您载入了该文档旧的修订版! 如果您保存了它,您就会用这些数据创建一份新的修订版。 <p>ok</p><h1 class="postTitle" style="margin: 0px; padding-bottom: 10px; font-size: 20px; color: rgb(70, 70, 70); background-image: url("//images.cnblogs.com/cnblogs_com/libaoheng/305804/o_br229512.link(en-us,MSDN.10).gif"); background-position: 0px 3px; background-size: initial; background-repeat: no-repeat; background-attachment: initial; background-origin: initial; background-clip: initial; padding-left: 30px; font-family: 微软雅黑, 宋体, Arial; white-space: normal;"><a class="postTitle2" href="https://www.cnblogs.com/jackhub/p/3187451.html" style="color: rgb(70, 70, 70); text-decoration-line: none;">Oracle用户的初始化问题</a></h1><p style="margin: 10px auto; line-height: 24px;"> 上一篇博文介绍了关于.bashrc和.bash_profile的相关知识,在oracle的用户设置中能发挥作用。</p><p style="margin: 10px auto; line-height: 24px;"> 场景:上周准备学习一下oracle,下载了安装文件后,在linux上新建了一个用户oracle,然后在这个用户下面安装的。也不太记得当时什么情况了,前些天通过oracle系统提供的sqlplus访问,一切正常。今天我想通过终端su到oracle用户下,然后用sqlplus命令打开sqlplus,遇到了不少问题,这里做一个总结。</p><p style="margin: 10px auto; line-height: 24px;">1. oracle用户密码忘记了。</p><p style="margin: 10px auto; line-height: 24px;">这个比较容易,打开terminal,登录到root用户下,更改oracle用户密码。</p><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important;">[root@win ~]# passwd oracle</pre><p style="margin: 10px auto; line-height: 24px;">2. 修改密码,登录后问题就多了,发现bash中不会显示成 [oracle@win ~] 这样的模式,而是 bash-4.1$。输入任何命令都不能运行,当然输入sqlplus也不行,提示找不到命令。</p><p style="margin: 10px auto; line-height: 24px;">查看oracle用户的HOME目录,上一篇文章提到了怎么查找,因为登录后任何命令都不能执行,所以不能通过命令来获取,要手动查。</p><p style="margin: 10px auto; line-height: 24px;">查看得知HOME=/u01/app/oracle</p><p style="margin: 10px auto; line-height: 24px;">查看此目录下的文件,发现没有.bashrc 和 .bash_profile文件,也就是说,没有设置任何环境变量与bash配置,当然不可能找到任何命令。</p><p style="margin: 10px auto; line-height: 24px;">解决方法:</p><p style="margin: 10px auto; line-height: 24px;">从其他用户那儿拷贝这两个文件,当然如果你非常熟悉的话也可以自己编写,不过建议拷贝过来做修改。</p><p style="margin: 10px auto; line-height: 24px;">我从Jack用户那儿拷来了这两个文件,将它们放在了oracle home目录下。应用这两个脚本:</p><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important;">bash-4.1 $ source .bashrcbash-4.1 $ source .bash_profile</pre><p style="margin: 10px auto; line-height: 24px;"> </p><p style="margin: 10px auto; line-height: 24px;">执行后,bash中就显示成 [oracle@win~] 这样的形式了。这是因为之前没有设置任何变量,执行脚本后,设置了SP1变量,显示恢复正常。</p><p style="margin: 10px auto; line-height: 24px;">此时常用的命令也可以执行了。</p><p style="margin: 10px auto; line-height: 24px;">3. 现在的问题就剩下这个了,网上有不少人讨论的,输入sqlplus后提示命令找不到。</p><p style="margin: 10px auto; line-height: 24px;">这种情况就是要环境变量的设置问题了。前一篇文章中已经提到了,我们可以在.bashrc中进行配置,一定会在bash启动时执行。最终的bash设置如下:</p><p style="margin: 10px auto; line-height: 24px;"> </p><p><span class="cnblogs_code_copy" style="padding-right: 5px; line-height: 1.5 !important;"><a title="复制代码" style="color: rgb(70, 70, 70); border: none !important;"><img src="/test_images/ueditor/php/upload/image/20190409/1554823235207119.gif" alt="复制代码"/></a></span></p><pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important;">[oracle@win ~]$ cat .bashrc # .bashrc # Source global definitionsif [ -f /etc/bashrc ]; then . /etc/bashrcfi# User specific aliases and functions ORACLE_BASE=/u01/app ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/xe ORACLE_SID=XE PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export PATH ORACLE_BASE ORACLE_HOME ORACLE_SID</pre><p><br/></p> 保存 预览 取消 编辑摘要 当您选择开始编辑本页,即寓示你同意将你贡献的内容按下列许可协议发布: CC Attribution-Share Alike 4.0 International