Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I created a DB connection test in PHP to connect to a remote oracle database. But it's throwing errors like
Failed to connect to Oracle
      Array ( [code] => 12546 [message] => ORA-12546: TNS:permission denied [offset] => 0 [sqltext] => )



PHP
$conn=oci_connect("ZZZZZ","zzzzz","zzzzzzzz");

If (!$conn)
    echo 'Failed to connect to Oracle';
 
else
    echo 'Succesfully connected with Oracle DB';
 $e = oci_error();   // For oci_connect errors pass no handle
 oci_close($conn);


What I have tried:

I gave 755 permission to oci8.so file but still it's not working.
Posted
Updated 15-Mar-22 9:29am
v2

1 solution

Based on this: Oci8Exception ORA-12546: TNS:permission denied (Page 1) — User support — Remi's RPM repository - Forum[^]

Quote:


Hi Remi!

After researching more, someone suggested this solution on stackoverflow:

Shell
# setsebool -P httpd_can_network_connect on


I haven't understood yet what it does but it worked for my case! He suggests that "this happens because the machine has SELinux activated, usually in the enforcing mode. I would not recommend to disable SELinux, but setting it to permissive looks to ease the process of identifying some problems with it. You can check SELinux status by sestatus."

For your info, the link is this
https://stackoverflow.com/questions/325 … ion-denied
 
Share this answer
 
Comments
Member 14362033 17-Mar-22 4:16am    
Hello,
I added tnsnames.ora file under this path ORACLE_HOME/network/admin
Maciej Los 17-Mar-22 5:40am    
And...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900