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
616
<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粉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 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.

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!