SQL 找不到 bash sqlplus 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28705341/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
bash sqlplus command not found
提问by al3
I am trying to install sqlplus on my mac following the tutorial here: https://tomeuwork.wordpress.com/2014/05/12/how-to-install-oracle-sqlplus-and-oracle-client-in-mac-os/comment-page-1/#comment-6
我正在尝试按照此处的教程在我的 mac 上安装 sqlplus:https: //tomeuwork.wordpress.com/2014/05/12/how-to-install-oracle-sqlplus-and-oracle-client-in-mac- os/comment-page-1/#comment-6
I have downloaded the two packages (basic and sqlplus) and created all the directories as it says, I moved the necessary files inside the directories. I created and copied the tnsnames.ora file with the contents:
我已经下载了两个包(basic 和 sqlplus)并按照它的说明创建了所有目录,我将必要的文件移到了目录中。我创建并复制了包含以下内容的 tnsnames.ora 文件:
MYDB=
(DESCRIPTION=
(ADDRESS=
(PROTOCOL=TCP)
(HOST=*********)
(PORT=1521)
)
(CONNECT_DATA=
(SERVER=dedicated)
(SID=MYDB-SID)
) )
And i created the .bash_profile as it says in the tutorial.
我按照教程中的说明创建了 .bash_profile 。
But what im stuck on is making the sqlplus
run.
但我坚持的是sqlplus
奔跑。
typing in sqlplus returns command not found.
键入 sqlplus 返回未找到命令。
in the tutorial it says i should use $ sqlplus username/password@database
在教程中它说我应该使用 $ sqlplus username/password@database
where do i get the username and database name from?, I haven't created one yet.
我从哪里获得用户名和数据库名称?,我还没有创建。
Thanks in advance.
提前致谢。
回答by idobr
According to your article, you should do the following:
根据您的文章,您应该执行以下操作:
$ vi ~/.bash_profile
Add the following line to the end of the file.
alias sqlplus='rlwrap sqlplus'
Now reload the .bash_profile:
$ source ~/.bash_profile
Looks like you missed these steps.
看起来你错过了这些步骤。
You can try to execute:
您可以尝试执行:
$rlwrap sqlplus
According to the comments below you do not have sqlplus in the $PATH. The value of $PATH looks wrong to me: duplicates, quotes.
根据下面的评论,您在 $PATH 中没有 sqlplus。$PATH 的值在我看来是错误的:重复、引号。
Option 1
选项1
Execute:
执行:
export PATH=/Applications/??or??acle/product/instantclient_64/11.2.0.4.0/bin:/usr/local/bin:/usr/bin:/bin:/us??r/s??bin:/sbin
Then execute in the same console:
然后在同一个控制台中执行:
$ sqlplus (or $ rlwrap sqlplus)
It will set value only for the current shell. The main idea is to have full path to the sqlplus binary in the $PATH.
它将仅为当前外壳设置值。主要思想是在 $PATH 中包含 sqlplus 二进制文件的完整路径。
Option 2
选项 2
Modify ~/.bash_profile
.
To save as a permanent environment variable edit ~/.bash_profile
. There are some details about setting PATH in the source article.
修改~/.bash_profile
. 要保存为永久环境变量,请编辑~/.bash_profile
. 源文章中有一些关于设置 PATH 的详细信息。
回答by Bjarte Brandt
Top down troubleshooting approach
自上而下的故障排除方法
Look for binary - use type
寻找二进制 - 使用类型
[bbrandt] ~/ $ type sqlplus
sqlplus is aliased to `rlwrap sqlplus'
Where is my binary.. hidden behind an alias, let's unalias
我的二进制文件在哪里..隐藏在别名后面,让我们取消别名
[bbrandt] ~/ $ unalias sqlplus
[bbrandt] ~/ $ type sqlplus
sqlplus is /u01/app/oracle/product/11.2.0/xe/bin/sqlplus
Found it! What happens if I modify my binary search-path?
找到了!如果我修改我的二进制搜索路径会发生什么?
[bbrandt] ~/ $ echo $PATH
/u01/app/oracle/product/11.2.0/xe/bin:/home/bbrandt/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin
[bbrandt] ~/ $ export PATH=/home/bbrandt/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin
Now, where is my binary?
现在,我的二进制文件在哪里?
[bbrandt] ~/ $ type sqlplus
bash: type: sqlplus: not found
[bbrandt] ~/ $
This is where you are... look in your $PATH variable
这就是你所在的地方......查看你的 $PATH 变量