Getting Error SQLSTATE[HY000] [2002] Connection refused on NAS Synology

前端 未结 5 1495
一个人的身影
一个人的身影 2021-01-14 05:37

I am making an under construction page which is hosted on my Synology NAS.

Visitors can subscribe with their email and get informed when the website will be availabl

5条回答
  •  深忆病人
    2021-01-14 06:10

    I had the same problem:

    SQLSTATE[HY000] [2002] Connection refused
    

    when attempting to connect to the MariaDB database running on my Synology NAS from php. Providing just username and password

    $conn = new PDO( "mysql:host=$servername;dbname=$dbname", $username, $password );
    

    didn't work, while specifying the port number, a solution found elsewhere, didn't work either:

    $conn = new PDO( "mysql:host=$servername;port=3307;dbname=$dbname", $username, $password );
    

    What does work (for me):

    $conn = new PDO("mysql:host=$servername:3307;dbname=$database", $login, $password);
    

    The port name is found when opening the MariaDB 10 properties window from the main menu on the Synology NAS. Apparently, the port=3307 specification does not have any effect, but does not give an error message either.

提交回复
热议问题