Forums

Mathias T
Mathias T
Offline
Resolved
0 votes
Greetings all,

First of all thank you for helping me yesterday, but as we are few steps further in my process. New problems have arisen.

To give you the thought process: I have a website hosted in a different country (normal webhosting), for our company we need by law to have a database server in our own country to store specific data. Yesterday I managed to get the database server running using dynamic DNS (because of you all). But now I need to connect it using php to the mysql (mariaDB) server on ClearOs.


As of now I have managed to connect partially ...

the following error is shown on my website (webhosted) after connected a config file.

"ERROR: Could not connect. Connection refused"

So there is a connection possible, however I've read that mysql doesn't allow remote access by default. I've been searching all day but all I can find are forum posts from over a decade ago.

Can someone tell me how to activate remote access?
Sunday, June 07 2020, 03:35 PM
Share this post:
Responses (5)
  • Accepted Answer

    Monday, June 08 2020, 07:02 AM - #Permalink
    Resolved
    0 votes
    Yhat you changes is the ports PHP will use to access mysql and not the port that mysql is listening on. What is the output of "netstat -npl | grep mysql". It I access it from my LAN or the server itself by telnet I get:
    [root@microserver ~]# telnet 172.17.2.5 3306
    Trying 172.17.2.5...
    Connected to 172.17.2.5.
    Escape character is '^]'.
    VHost 'wpad.local-7x.howitts.local' is not allowed to connect to this MariaDB serverConnection closed by foreign host.
    I have not tried from the internet and don't intend to open the port.

    On you server you can also run tcpdump. You need to know your external interface name then:
    tcpdump -nni your_external_interface port 3306
    You should see some traffic when you try to connect.
    The reply is currently minimized Show
  • Accepted Answer

    Mathias T
    Mathias T
    Offline
    Monday, June 08 2020, 04:14 AM - #Permalink
    Resolved
    0 votes
    Nick Howitt wrote:

    Your knowledge is probably beyond mine. Can you telnet into 13306? If you can't, do you see the packets arriving in ClearOS for 13306? You can use tcpdump to check. To be honest I wouldn't expect any different behaviour if MariaDB is listening on 3306 or 13306.


    telnet 192.168.0.134 port 3306
    CONNECTION REFUSED

    telnet 192.168.0.134 port 13306
    CONNECTION REFUSED

    telnet [external] port 3306
    CONNECTION TIMED OUT

    telnet [external] port 13306
    CONNECTION TIMED OUT


    tcpdump port 3306
    tcpdump port 13306

    both showed no activity when accessing the page.

    However.
    in my config.php file

    define('DB_SERVER', '[hostname]:13306');
    ERROR: Could not connect. Connection refused

    define('DB_SERVER', '[hostname]:3306');
    ERROR: Could not connect. Connection timed out
    The reply is currently minimized Show
  • Accepted Answer

    Sunday, June 07 2020, 07:20 PM - #Permalink
    Resolved
    0 votes
    Your knowledge is probably beyond mine. Can you telnet into 13306? If you can't, do you see the packets arriving in ClearOS for 13306? You can use tcpdump to check. To be honest I wouldn't expect any different behaviour if MariaDB is listening on 3306 or 13306.
    The reply is currently minimized Show
  • Accepted Answer

    Mathias T
    Mathias T
    Offline
    Sunday, June 07 2020, 06:46 PM - #Permalink
    Resolved
    0 votes
    Nick Howitt wrote:

    Mysql (Mariadb) seems to be listening on all interfaces on tcp:3306. I presume you've port forwarded to it? If you have can you restrict the port forward to a single source IP - your web server - or you'll have hosts of attempts to connect.

    What have you found to say mysql is rejecting external queries?


    Hey Nick,

    Should the fact that I do receive the message "ERROR: Could not connect. Connection refused" mean that it started to make a connection? I have set the TCP port for the server to 13306 (tried it with 3306 at first, but with that it just keeps loading and eventually it gives a 404). With the 13306 i get the message connecton refused.


    So when I load the website page (with the config.php as required once) i get the following text back ""ERROR: Could not connect. Connection refused"".
    The reply is currently minimized Show
  • Accepted Answer

    Sunday, June 07 2020, 05:47 PM - #Permalink
    Resolved
    0 votes
    Mysql (Mariadb) seems to be listening on all interfaces on tcp:3306. I presume you've port forwarded to it? If you have can you restrict the port forward to a single source IP - your web server - or you'll have hosts of attempts to connect.

    What have you found to say mysql is rejecting external queries?
    The reply is currently minimized Show
Your Reply