gpt4 book ai didi

PHP oci_connect() TNS :could not resolve the connect identifier (ORA-12154)

转载 作者:可可西里 更新时间:2023-11-01 13:09:20 26 4
gpt4 key购买 nike

我正在 Ubuntu 服务器上测试一些 PHP 代码,并通过“tnsping”命令检查 oracle 数据库连接

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.14)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ORCL) (SID = ORCL)))
OK (10 msec)

但是,PHP 中的 oci_connect 函数显示如下警告

Warning: oci_connect(): ORA-12154: TNS:could not resolve the connect identifier specified in /usr/local/ipm5/wui/manager/123.bih on line 6 2

当然,OCI8 已启用(通过 phpinfo 检查)和一些环境(PATHORACLE_BASEORACLE_HOMEORACLE_SID ,TNS_ADMIN,LD_LIBRARY_PATH ) 变量设置到 /etc/bash.bashrc

有人推荐吗??问题是什么。

最佳答案

而不是 ORCL,您可能希望将整个字符串放入 oci_connect

(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.14)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ORCL) (SID = ORCL)))

PHP代码:

oci_connect($username, $password, '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.3.14)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ORCL) (SID = ORCL)))');

检查phpinfo()输出的“Environment”部分,如果你没有ORACLE_HOME,TNS_ADMIN,你需要将它们提供给你的PHP运行环境,对于使用 php_module 编译的 apache

export ORACLE_HOME=/path/to/oracle_home
export TNS_ADMIN=/path/to/tns_admin
apachectl start

对于 php-cgi 或 php-fpm

export ORACLE_HOME=/path/to/oracle_home
export TNS_ADMIN=/path/to/tns_admin
/script/to/start/fpm

关于PHP oci_connect() TNS :could not resolve the connect identifier (ORA-12154),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20345605/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com