Home  >  Article  >  php教程  >  Win7 64位系统下PHP连接Oracle数据库,win7oracle

Win7 64位系统下PHP连接Oracle数据库,win7oracle

WBOY
WBOYOriginal
2016-06-13 09:26:511001browse

Win7 64位系统下PHP连接Oracle数据库,win7oracle

下面讲下配置过程

一、下载oracle instantclient

下载地址:http://www.oracle.com/technetwork/topics/winx64soft-089540.html

下载 instantclient-basic-windows.x64-11.2.0.4.0

解压路径:D:\Program Files (x86)\Oracle64Client\instantclient_11_2

*注:客户端需要对应数据库版本。

二、配置系统环境变量

在PATH环境变量后加入:;D:\Program Files (x86)\Oracle64Client\instantclient_11_2

三、配置PHP支持OCI扩展

修改配置文件php.ini

开启配置如下

四、重启Apache服务测试

使用探针函数phpinfo()查看扩展是否开启,如果出现下图说明扩展开启

五、测试数据库连接

在站点根目录编写oracle.php,我连接的是虚拟机CentOS中的Oralce数据库

代码如下:

<&#63;php
  $conn = ocilogon('test','test','192.168.23.131:1521/dev');
  if (!$conn)
  {
    $Error = oci_error();
    print htmlentities($Error['message']);
    exit;
  }
  else
  {
    echo "Connected Oracle Successd!"."<br>";
    ocilogoff($conn);
  }
&#63;>

浏览器地址栏输入 http://localhost/oracle.php

显示Connected Oracle Successd!说明数据库连接成功。

WIN7 64位连接ORACLE数据库问题

我遇到过,并且解决了。
单位的服务器配置的CENTOS 5.5 X64,我的电脑也是win7 x64,安装的oracle 10g x86 client,可以通过sqlplus@的方式连接到数据库,但是安装了toad和pl/sql就是连接不上。起初我也问是不是一定要把操作系统换成32位。
后来经过测试,发现原因很简单,因为安装在了C盘的Program Files (X86)文件夹下。这个文件夹很特殊,是为了提高64位兼容性,搞得兼容32位模式的文件夹,一般32位的软件默认安装在这,而且会以32位运行,所以会导致toad,PL/SQL无法连接。
所以解决方法非常简单,只要把PL/SQL,TOAD安装在D盘,就可以通过连接。
 

win7 64位操作系统,plsql怎连接oracle数据库?

win7+64位+Oracle+11g+64位下使用PLSQL+Developer+的解决办法

1)安装Oracle 11g 64位 (这部分就不说了吧)
2)安装32位的Oracle客户端( instantclient-basic-win32-11.2.0.1.0)
下载instantclient-basic-win32-11.2.0.1.0.zip (一定得是32位的,不要下错了版本,Oracle官网有下载),将其解压至Oracle安装目录的Product下(本机命名为:instantclient_11_2):D:\Oracle\app\dd\product\instantclient_11_2。
拷贝数据库安装根目录下的一个目录D:\Oracle\app\dd\product\11.2.0\dbhome_1\NETWORK到Oracle客户端目录下D:\Oracle\app\dd\product\instantclient_11_2(其实只需要 NETWORK\ADMIN\tnsnames.ora)
3)安装PL/SQL Developer
安装 PL/SQL Developer,在perference->Connection里面设置OCI Library和Oracle_Home,例如本机设置为:
Oracle Home :D:\Oracle\app\dd\product\instantclient_11_2
OCI Library :D:\Oracle\app\dd\product\instantclient_11_2\oci.dll
4) 设置环境变量(修改环境变量)
对于NLS_LANG环境变量, 最好设置成和数据库端一致, 首先从数据库端查询字符集信息:
SQL> select userenv('language') nls_lang from dual;
NLS_LANG
----------------------------------------------------
SIMPLIFIED CHINESE_CHINA.ZHS16GBK
右击"我的电脑" - "属性" - "高级" - "环境变量" - "系统环境变量":
1>.点击"新建", 变量名设置为"NLS_LANG", 变量值设置为"SIMPLIFIED CHINESE_CHINA.ZHS16GBK", 点击"确定";
2>.新建环境变量“TNS_ADMIN”,值为“D:\Oracle\app\dd\product\instantclient_11_2”
最后点击"确定"退出.

启动 PL/SQL Developer ,运行无问题。...余下全文>>
 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn