简体   繁体   中英

Problems with oci_connect ORA-12541: TNS:no listener

Yo guys. I have the following snippet:

$conn = oci_connect('user', 'pass', '(DESCRIPTION=
     (ADDRESS_LIST=
       (ADDRESS=(PROTOCOL=TCP)
         (HOST=myhost.net)(PORT=1521)
       )
     )
     (CONNECT_DATA=
         (SERVER = DEDICATED)
         (SERVICE_NAME = MYSERVICE)
     )
 )');

That is giving me the following error: oci_connect: ORA-12541: TNS:no listener

That's the first time I try to connect to a oracle database. What am I doing wrong? I'm on Windows.

Are you sure your TNS Listener service is running? You can check it by typing services.msc in the run dialogue box and you'll get a list of services running. If you do a quick lookup for Oracle, you will find TNS Listener. I am assuming your TNS entries are correct.

I was struggling with same error to connect oracle DB with codeigniter and finally after 2 days found some solution:

Note: This steps worked for me in Wamp server - windows 10

  1. First download instant client from oracle offical website and extract it into some folder https://www.oracle.com/database/technologies/instant-client/downloads.html
  2. Update environment variable PATH with instant client path ie D:\php\instantclient_21_3
  3. Edit your php.ini and uncomment extension=php_oci8_12c.dll
  4. Restart your Wamp server

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM