Mac 上的 Oracle Sqlplus 客户端

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19152403/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:58:33  来源:igfitidea点击:

Oracle Sqlplus client on Mac

macosoracle32bit-64bitsqlplus

提问by Ryainad

I want to install SqlPlus client on my Mac, which is 64-bit. Firstly, I installed sqlplus for 64-bit, but I had error: "Segmentation fault: 11"Then I installed sqlplus for 32-bit, but still have a problem it says: ../libsqlplus.dylib: no suitable image found ../libsqlplus.dylib: mach-o, but wrong architecture

我想在我的 64 位 Mac 上安装 SqlPlus 客户端。首先,我为 64 位安装了 sqlplus,但出现错误: “分段错误:11”然后我为 32 位安装了 sqlplus,但仍然有一个问题: ../libsqlplus.dylib:找不到合适的图像。 ./libsqlplus.dylib:mach-o,但架构错误

I have used many tutorials, but still didn't solve this problem.

我已经使用了很多教程,但仍然没有解决这个问题。

回答by Alex Poole

The 11gR2 64-bit instant client works on 10.8.5. It doesn't matter if the database you're connecting to is still 10g, you can use the 11g client. I'm not aware of any reason to still use the old version, unless maybe you need a specific ojdbcversion; but presumably there are use cases or it wouldn't still be listed prominently for download. Anyway, this demonstrates a fresh install:

11gR2 64 位即时客户端适用于 10.8.5。如果您连接的数据库仍然是 10g 没有关系,您可以使用 11g 客户端。我不知道有什么理由仍然使用旧版本,除非您可能需要特定ojdbc版本;但大概有用例,否则它仍然不会在显着位置列出以供下载。无论如何,这演示了全新安装:

$ unzip instantclient-basic-macos.x64-11.2.0.3.0.zip
Archive:  instantclient-basic-macos.x64-11.2.0.3.0.zip
  inflating: instantclient_11_2/BASIC_README  
  inflating: instantclient_11_2/adrci  
  inflating: instantclient_11_2/genezi  
  inflating: instantclient_11_2/libclntsh.dylib.11.1  
  inflating: instantclient_11_2/libnnz11.dylib  
  inflating: instantclient_11_2/libocci.dylib.11.1  
  inflating: instantclient_11_2/libociei.dylib  
  inflating: instantclient_11_2/libocijdbc11.dylib  
  inflating: instantclient_11_2/ojdbc5.jar  
  inflating: instantclient_11_2/ojdbc6.jar  
  inflating: instantclient_11_2/uidrvci  
  inflating: instantclient_11_2/xstreams.jar  

$ unzip instantclient-sqlplus-macos.x64-11.2.0.3.0.zip
Archive:  instantclient-sqlplus-macos.x64-11.2.0.3.0.zip
  inflating: instantclient_11_2/SQLPLUS_README  
  inflating: instantclient_11_2/glogin.sql  
  inflating: instantclient_11_2/libsqlplus.dylib  
  inflating: instantclient_11_2/libsqlplusic.dylib  
  inflating: instantclient_11_2/sqlplus  

$ export DYLD_LIBRARY_PATH=$PWD/instantclient_11_2
$ $PWD/instantclient_11_2/sqlplus

SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 3 09:49:06 2013

Copyright (c) 1982, 2012, Oracle.  All rights reserved.

Enter user-name: 

You can create a tnsnames.oraanywhere; I put this in the same instant client_11_2directory:

您可以在tnsnames.ora任何地方创建一个;我把它放在同一个instant client_11_2目录中:

$ export TNS_ADMIN=$PWD/instantclient_11_2
$ echo "TEST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = <db_server>)(PORT = <listener port>))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = <full_db_service_name>)
    )
  )
" > $TNS_ADMIN/tnsnames.ora

$ $PWD/instantclient_11_2/sqlplus user/password@test

SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 3 09:55:14 2013

Copyright (c) 1982, 2012, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> 

The 32-bit version works fine too:

32 位版本也可以正常工作:

$ rm -rf $PWD/instantclient_11_2
$ unzip instantclient-basic-macos.x32-11.2.0.3.0.zip
$ unzip instantclient-sqlplus-macos.x32-11.2.0.3.0.zip
$ export DYLD_LIBRARY_PATH=$PWD/instantclient_11_2
$ export TNS_ADMIN=$PWD/instantclient_11_2
$ echo "TEST = ..." > TNS_ADMIN/tnsnames.ora
$ $PWD/instantclient_11_2/sqlplus user/password@test

SQL*Plus: Release 11.2.0.3.0 Production on Thu Oct 3 10:06:19 2013

Copyright (c) 1982, 2012, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> 

You can of course move or rename the instanstclient_11_2directory to anything you want, just make sure your DYLD_LIBRARY_PATH, TNS_ADMINand (to make life easier) PATHenvironment variables follow it. If you have more than one version installed make sure the variables only point to one version at a time so you pick up the right libraries etc. (If you do have multiple versions, making TNS_ADMINsomewhere central makes much more sense as you only need to maintain one copy of tnsnames.ora).

您当然可以将instanstclient_11_2目录移动或重命名为您想要的任何内容,只需确保您的DYLD_LIBRARY_PATH,TNS_ADMIN和(为了让生活更轻松)PATH环境变量跟随它。如果您安装了多个版本,请确保变量一次只指向一个版本,以便您选择正确的库等(如果您确实有多个版本,则将TNS_ADMIN某个地方放在中央更有意义,因为您只需要维护的一份tnsnames.ora)。

I'd need to check, but I think you might have to still use the 32-bit version if you're connecting from Java; it has to batch the architecture of Java itself so I guess it depends which version of that you have installed.

我需要检查一下,但我认为如果您从 Java 连接,您可能仍需要使用 32 位版本;它必须批处理 Java 本身的体系结构,所以我想这取决于您安装的是哪个版本。