bash: sqlplus: command not found 解决方法
转载:https://shiguanghui.iteye.com/blog/1939054
1: bash: sqlplus: command not found 解决方法
-
查看环境.bash_profile 配置
[root@localhost ~]# find -name .bash_profile ./usr/local/oracle11gr2/oracle/.bash_profile ./etc/skel/.bash_profile ./root/.bash_profile ./home/oracle/.bash_profile(这个是我oracle用户的环境变量)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
-
查看环境变量配置文件
[oracle@localhost ~]$ vi .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_BASE=/usr/local/oracle11gr2/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 export ORACLE_SID=cssid export ORACLE_OWNER=oracle export PATH=$PATH:$ORACLE_HOME/bin:$HOME/bin
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
这里的环境变量都已经配置了。
-
登录oralce测试
[root@localhost ~]# sqlplus /nolog -bash: sqlplus: command not found
- 1
- 2
- 3
找不到sqlplus 可执行文件找不到。 所以我们要去/usr/bin/ 下查看sqlplus 是否存在
-
查看sqlplus 是否存在
[root@localhost oracle]# cd /usr/bin/ [root@localhost bin]# find -name sqlplus [root@localhost bin]#
- 1
- 2
- 3
- 4
- 5
结果发现不存在
- 要么去sqlplus根目录下执行,要么做个ln到/usr/bin/下
sqlplus根目录:/usr/local/oracle11gr2/oracle/product/11.2.0/db_1/bin/sqlplus
这里我们做ln。这样操作方便很多
ln -s /usr/local/oracle11gr2/oracle/product/11.2.0/db_1/bin/sqlplus /usr/bin
- 1
-
测试结果;
[oracle@localhost bin]$ sqlplus /nolog Error 6 initializing SQL*Plus SP2-0667: Message file sp1<lang>.msb not found SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
这里sqlplus已经找到了。当然这里又发现了其他的错误。
这个是环境变量没有生效的原因。所以我们soruce一下,使得马上生效
[oracle@localhost ~]$ source .bash_profile
- 1
再测试就ok了。
[oracle@localhost ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Mon May 11 12:51:24 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 79694068 bytes
Database Buffers 83886080 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL>