php: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it

后端 未结 6 1619
暖寄归人
暖寄归人 2020-12-20 02:33

I have create register and login form using php. And i had took the source from google.

So i have added all the corresponding code, when run index.php.

It sh

相关标签:
6条回答
  • 2020-12-20 03:03

    For Drupal Users -

    This happens generally because of max_execution time for communicating server to mysql. Increase max execution time from 60 sec to upper limit you want and try refresh the page again.

    It worked for me.

    0 讨论(0)
  • 2020-12-20 03:05

    didn't you say your mysql port is 3306:

    $db = new PDO("mysql:host=".DBHOST.";port=8889
    //------------------------------------------^
    

    this might help:

    $db = new PDO("mysql:host=".DBHOST.";port=3306
    
    0 讨论(0)
  • 2020-12-20 03:15

    Sasi, if your running this on a local server it may be your setup for windows the local server need to be configured to send email on.

    Here you can find how to configure XAMPP to send mail from localhost.

    Sorry that i answer you here, but i don't have enough reputation to make comments :D

    0 讨论(0)
  • 2020-12-20 03:23

    $db = new PDO("mysql:host=".DBHOST.";port=3306;dbname=".DBNAME, DBUSER, DBPASS);

    you should change the port number to default: 3306! hope this helps

    0 讨论(0)
  • 2020-12-20 03:25

    I suffered this error too. I did following things: 1. find out the port number used by mysql. In phpmyadmin, I ran the following sql:

    show variables;
    

    it shows a list of variables of mysql. scroll down, you will find port number.

    1. I edited the php code like this:

    $dsn = 'mysql:host=127.0.0.1;port=3307; dbname=learnphpfast';

    it worked like a charm!

    0 讨论(0)
  • 2020-12-20 03:28

    This error usually occurs when some other app like skype and IIS are using ports of Apache i.e. 80 and mysql server i.e. 3306

    You can eighter uninstall these apps or change port numbers of the localhost to something else and make correct changes in settings.php

    0 讨论(0)
提交回复
热议问题