温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Oracle下sqlplus无法使用命令退格删除和历史记录的解决方法--使用rlwrap

发布时间:2020-04-28 12:52:42 来源:网络 阅读:1646 作者:xjsunjie 栏目:关系型数据库

   

    一般通过SecureCRT或putty等SSH客户端远程登录Linux下oracle的时候,使用sqplus连接数据库,输错字符后按Backspace键或Del键删除时,会出现^H或其他乱七八糟的的字符,会感觉非常别扭不习惯,而且影响使用效率。针对此问题,小结了一下。

一、安装相应的软件包

首先配置本地YUM源

然后

yum -y install readline*

Running Transaction

  Installing : ncurses-devel-5.7-3.20090208.el6.x86_64                               1/2 

  Installing : readline-devel-6.0-4.el6.x86_64                                       2/2 

Installed products updated.

  Verifying  : readline-devel-6.0-4.el6.x86_64                                       1/2 

  Verifying  : ncurses-devel-5.7-3.20090208.el6.x86_64                               2/2 

等待安装完成

然后从网上下载rlwrap-0.37.tar包

[root@rac1 home]#tar -xvf  rlwrap-0.37.tar

[root@rac1 home]# cd rlwrap-0.37

[root@rac1 rlwrap-0.37]# ls -l

总用量 472

-rw-rw-r-- 1  500  500  35029 4月  30 2010 aclocal.m4

-rw-r--r-- 1  500  500    638 8月  15 2006 AUTHORS

-rw-r--r-- 1  500  500   4267 5月   5 2010 BUGS

-rw-r--r-- 1  500  500    105 8月  10 2003 ChangeLog

drwxrwxr-x 2  500  500   4096 5月   5 2010 completions

-rw-rw-r-- 1  500  500   7042 4月  30 2010 config.h.in

-rw-r--r-- 1 root root  67839 9月   1 17:00 config.log

-rwxr-xr-x 1  500  500 222847 4月  30 2010 configure

-rw-r--r-- 1  500  500  11521 4月  30 2010 configure.ac

-rw-r--r-- 1  500  500  17992 8月   8 2006 COPYING

drwxrwxr-x 2  500  500   4096 5月   5 2010 doc

drwxrwxr-x 2  500  500   4096 5月   5 2010 filters

-rw-r--r-- 1  500  500   2019 11月 23 2009 INSTALL

-rw-r--r-- 1  500  500   1272 1月  23 2010 Makefile.am

-rw-rw-r-- 1  500  500  28316 4月  30 2010 Makefile.in

-rw-r--r-- 1  500  500  16788 4月  30 2010 NEWS

-rw-r--r-- 1  500  500   1394 10月 24 2007 PLEA

-rw-r--r-- 1  500  500   3070 1月   8 2010 README

drwxrwxr-x 2  500  500   4096 5月   5 2010 src

drwxrwxr-x 2  500  500   4096 5月   5 2010 test

-rw-r--r-- 1  500  500    310 4月  16 2010 TODO

drwxrwxr-x 2  500  500   4096 5月   5 2010 tools

[root@rac1 rlwrap-0.37]# ./configure

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for a thread-safe mkdir -p... /bin/mkdir -p


[root@rac1 rlwrap-0.37]# make

[root@rac1 rlwrap-0.37]# make install


二:配置使用rlwrap

[root@oracle11g rlwrap-0.30]# vi /home/oracle/.bash_profile

在首部或尾部添加

alias  sqlplus='rlwrap sqlplus'

alias  lsnrctl='rlwrap lsnrctl'

alias  rman='rlwrap rman'

stty erase ^h


如果出现rlwrap命令找不到,请配置PATH

PATH=$PATH:$HOME/bin:/home/rlwrap-0.37/src


使修改的变量执行生效

# source .bash_profile



三.进入oracle连接用户测试

#su - oracle

sqlplus / as sysdba

SQL> show user

 

之后再用命令sqlplus / as sysdba 连接数据库时就会调用rlwrap这个工具,使得Linux下的SQL Plus可以像Windows下的那样使用了。


补充:如果sqlplus命令用不了,可以做如下设置

[oracle@rac1 ~]$ sqlplus /nolog

bash: sqlplus: command not found

[oracle@rac1 ~]$ ln -s $ORACLE_HOME/bin/sqlplus /usr/bin

ln: creating symbolic link `/usr/bin/sqlplus' to `/bin/sqlplus': Permission deni ed

[oracle@rac1 ~]$ su - root

Password:

[root@rac1 ~]# ln -s $ORACLE_HOME/bin/sqlplus  /usr/bin

[root@rac1 ~]# su - oracle

[oracle@rac1 ~]$ sqlplus /nolog

SQL> conn / as sysdba

Connected to an idle instance.

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI