操作步骤:
访问php项目,提示Warning ,mysqlli_connect():(HY000/2002):No such fileor directory in xxxxxx on line 2
解决方法:
配置文件中,连接数据库的ip由localhost 改成127.0.0.1
如下配置
<?php $conn=mysqli_connect("127.0.0.1","root","123456","db_shop") or die("数据库服务器连接错误".mysqli_error());//连接到MySQL服务器 mysqli_query($conn,"set names utf8");//设置编码格式 ?>