今天登录一台服务器用roote用户登录的,在切换到oracle用户,执行sqlplus sys/ as sysdba进入数据库提示如下错误:
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
在/home/oracle目录下查看文件.bash_profile,它是隐藏文件。
$cat.bash_profile #.bash_profile #Getthealiasesandfunctions if[-f~/.bashrc];then .~/.bashrc fi #Userspecificenvironmentandstartupprograms PATH=$PATH:$HOME/bin exportPATH exportORACLE_BASE=/u01/app/oracle exportORACLE_HOME=/u01/app/oracle/product/11.1.0/db_1 exportORACLE_SID=orcl exportPATH=$ORACLE_HOME/bin:$PATH exportLD_LIBRARY_PATH=$ORACLE_HOME/lib LANG=zh_CN.UTF-8;exportLANG NLS_LANG='SIMPLIFIEDCHINESE_CHINA.AL32UTF8';exportNLS_LANG
[oracle@localhost ~]$ cd $ORACLE_HOME
-bash: cd: /u01/app/oracle/product/11.1.0/db_1: 没有那个文件或目录
发现oracle安装定义的家目录是在/u01/app/oracle/product/11.1.0/db_1目录下的 u01目录是root用户的权限,在切回到root用户,执行如下命令: [root@localhost~]#cd$ORACLE_HOME [root@localhostdbhome_1]#pwd /u01/app/oracle/product/11.2.0/dbhome_1 [root@localhostdbhome_1]#sqlplus/assysdba 或是 [root@localhostdbhome_1]#cdbin [root@localhostdbhome_1]#pwd /u01/app/oracle/product/11.2.0/dbhome_1/bin [root@localhostbin]#./sqlplus/assysdba sql*Plus:Release11.2.0.4.0ProductiononThuOct1217:20:482017 Copyright(c)1982,2013,Oracle.Allrightsreserved. Enterpassword: Connectedto: OracleDatabase11gEnterpriseEditionRelease11.2.0.4.0-64bitProduction WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions sql>
问题解决!