一般通過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包
[[email protected] home]#tar -xvf rlwrap-0.37.tar
[[email protected] home]# cd rlwrap-0.37
[[email protected] 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
[[email protected] 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
[[email protected] rlwrap-0.37]# make
[[email protected] rlwrap-0.37]# make install
二:配置使用rlwrap
[[email protected] 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指令用不了,可以做如下設定
[[email protected] ~]$ sqlplus /nolog
bash: sqlplus: command not found
[[email protected] ~]$ ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
ln: creating symbolic link `/usr/bin/sqlplus' to `/bin/sqlplus': Permission deni ed
[[email protected] ~]$ su - root
Password:
[[email protected] ~]# ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
[[email protected] ~]# su - oracle
[[email protected] ~]$ sqlplus /nolog
SQL> conn / as sysdba
Connected to an idle instance.