Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
435 views
in Technique[技术] by (71.8m points)

php - Mysql No connection could be made because the target machine actively refused it

I know there are many people already asked this , but this people mostly forgot password of blocked by firewall which I have none of this situations .

I am developing with php , and I need to connect to remote database to let all my team work on it .

localhost was just going fine , but when I tried to switch it gave me this error

No connection could be made because the target machine actively refused it.

and this is my code where I want to connect to .nf.biz database :

$db=mysqli_connect($host,$user,$password,$db_name,3306);
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your MySQL server is only accepting connections on *nix socket (/var/run/mysqld/mysqld.sock if you're running Ubuntu) or for localhost only.

You have to edit your my.cnf (on Ubuntu again is located in /etc/mysql/my.cnf) and change the following:

bind-address = 0.0.0.0

And comment out the following

#skip-networking

Finally restart MySQL.

Be careful with that, if your MySQL machine is accessible from public Internet will be accepting connections from everybody!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...