Mysql connection cannot be established because the target machine actively refuses the connection
P粉957723124
P粉957723124 2023-08-22 19:04:28
0
2
591

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.

I am developing in php and need to connect to a remote database for my team to use together.

Everything is fine on localhost, but when I try to switch, I get the following error:

The connection cannot be established because the target machine actively refused the connection.

Here is the code I want to connect to the .nf.biz database:

$db=mysqli_connect($host,$user,$password,$db_name,3306);


P粉957723124
P粉957723124

reply all (2)
P粉738248522

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!

    P粉818306280

    Although it may be late, but for future visitors,

    I discovered then thatbiz.nfrefuses any connections from external sources, meaning only those hosted onbiz.nfOnly web applications on the Internet can access their database, otherwise you will be denied.

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!