[英]Warning: mysqli_connect(): (HY000/2002): Connection refused in
Cannot figure out why I am getting this error? 无法弄清楚为什么我收到此错误?
Warning: mysqli_connect(): (HY000/2002): Connection refused in 警告:mysqli_connect():( HY000 / 2002):拒绝连接
Here the code: 这里的代码:
$con = mysqli_connect('localhost:3306', '********', '********');
mysqli_select_db ($con, "id9873966_search") or die mysqli_error($con));
If you're using the standard port 3306 you should just be able to write 如果您使用标准端口3306,您应该只能写
$con = mysqli_connect("localhost", "username", "password", "id9873966_search");
Assuming you actually have a db named id9873966_search 假设您实际上有一个名为id9873966_search的数据库
Additionally, if you're on Windows PC you can open CMD as admin and run 此外,如果您使用的是Windows PC,则可以以管理员身份打开CMD并运行
netstat -a -b
This will generate a list of services listening on what ports so you can verify you are in fact using port 3306 on localhost. 这将生成一个监听端口的服务列表,以便您可以验证您实际上是在localhost上使用端口3306。 You can also open "Services" in Windows and ensure that your DB is installed and listening. 您还可以在Windows中打开“服务”并确保安装和侦听数据库。
It may also be necessary to add a firewall rule on you machine. 可能还需要在您的计算机上添加防火墙规则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.