Mysql No connection could be made because the targ

2019-01-09 08:07发布

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

i want to connect to .nf.biz database

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

thanks erverone

8条回答
我想做一个坏孩纸
2楼-- · 2019-01-09 08:51

I fixed this by setting the bind-address in my.cnf to the server's public IP address:

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = SERVER_IP_ADDRESS
查看更多
Viruses.
3楼-- · 2019-01-09 08:52

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!

查看更多
登录 后发表回答