search

Home  >  Q&A  >  body text

Mysql connection cannot be established because the target machine actively refuses the connection

<p>I know a lot of people have asked this question, but most of these people have forgotten their passwords that are blocked by firewalls, and I have not encountered this situation. </p> <p>I am developing in php and need to connect to a remote database for my team to use together. </p> <p>Everything is fine on localhost, but when I try to switch, I get the following error: </p> <blockquote> <p>The connection cannot be established because the target machine actively refused the connection. </p> </blockquote> <p>Here is the code I want to connect to the .nf.biz database: </p> <pre class="brush:php;toolbar:false;">$db=mysqli_connect($host,$user,$password,$db_name,3306);</pre> <p><br /></p>
P粉957723124P粉957723124461 days ago657

reply all(2)I'll reply

  • P粉738248522

    P粉7382485222023-08-23 11:18:17

    Your MySQL server only accepts *nix sockets (/var/run/mysqld/mysqld.sock if you use Ubuntu) or local connections only.

    You need to edit your my.cnf file (located at /etc/mysql/my.cnf in Ubuntu) and make the following changes:

    bind-address = 0.0.0.0

    and comment out the following:

    #skip-networking

    Finally restart MySQL.

    Please note that if your MySQL server is accessible from the public internet, connections from anyone will be accepted!

    reply
    0
  • P粉818306280

    P粉8183062802023-08-23 00:16:57

    Although it may be late, but for future visitors,

    I discovered then that biz.nf refuses any connections from external sources, meaning only those hosted on biz.nf Only web applications on the Internet can access their database, otherwise you will be denied.

    reply
    0
  • Cancelreply