1.错误代码

   //主机名
$db_host = 'localhost';
//用户名
$db_user = 'jaing';
//密码
$db_password = '1';
//数据库名
$db_name = 'rongShop';
//端口
$db_port = '3306';
//连接数据库
$conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die('连接数据库失败!');

错误原因:未加端口参数;用户名填写错误

修改db_host,$db_user即可

   //主机名
$db_host = 'localhost:3306';
//用户名
$db_user = 'jiang';
//密码
$db_password = '1';
//数据库名
$db_name = 'rongShop';
//端口
$db_port = '3306';
//连接数据库
$conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die('连接数据库失败!');

php 连接数据库 Warning: mysqli_connect(): (HY000/2002): No such file or directory in的更多相关文章

  1. mac 连接mysql提示 Warning: mysqli::real_connect(): (HY000/2002): No such file or directory

    mac 连接mysql的时候提示 Warning: mysqli::real_connect(): (HY000/2002): No such file or directory [说明1]MAC下M ...

  2. TP连接数据库报错:SQLSTATE[HY000] [2002] No such file or directory

     连接数据库报错:“SQLSTATE[HY000] [2002] No such file or directory”. 出现这个问题的原因是PDO无法找到mysql.sock或者mysqld.soc ...

  3. Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory解决方法

    今天用pdo连接mysql遇到一个奇怪的问题,host设为127.0.0.1可以连接成功,设为localhost就会报如下的错误: PHP Fatal error:  Uncaught excepti ...

  4. 无法登录 MySQL 服务器 mysqli_real_connect() (HY000 2002) No such file or directory

    mysqli_real_connect(): (HY000/2002): No such file or directory change localhost to 127.0.0.1 in conf ...

  5. [PDOException] SQLSTATE[HY000] [2002] No such file or directory

    编译安装PHP7之后,在安装mysql之后,用pdo操作数据库的时候,出现了此错误[PDOException] SQLSTATE[HY000] [2002] No such file or direc ...

  6. laravel 报错SQLSTATE[HY000] [2002] No such file or directory

    在mac中执行php artisan migrate时报错 SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from i ...

  7. Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory

    执行下面的代码报错: $pdo = new PDO('mysql:dbname=db_test;host=localhost', 'root', '123456'); PHP Fatal error: ...

  8. YII 错误 SQLSTATE[HY000] [2002] No such file or directory

    在使用yii的yii\db\Connnection时发生错误 <?php namespace app\controllers; use yii\web\Controller; use yii\d ...

  9. Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002] No such file or directory'

    1.根本原因在http://askubuntu.com/questions/606732/php-fatal-error-uncaught-exception-pdoexception-with-me ...

随机推荐

  1. jquery easyui控件事件监听委托给jquery事件监听,keyup取最新值问题

    <div id="<?php echo NS; ?>toolbar"> <div style="padding:5px"> ...

  2. [NOIP2015]运输计划 题解

    题目背景 公元 2044 年,人类进入了宇宙纪元. 题目描述 L 国有 n 个星球,还有 n-1 条双向航道,每条航道建立在两个星球之间,这 n-1 条 航道连通了 L 国的所有星球. 小 P 掌管一 ...

  3. [CSP-S模拟测试96]题解

    以后不能再借没改完题的理由不写题解了…… A.求和 求$\sum \sum i+j-1$ 柿子就不化了吧……这年头pj都不考这么弱智的公式化简了…… 坑点1:模数不定,可能没有2的逆元,那么只要先把乘 ...

  4. centos7中yum安装lamp环境

    一.准备工作 1.1 环境 操作系统:centos7(CentOS-7-x86_64-Minimal-1708) 硬件:(这个根据项目运行和配置建议设置,一般我先配个1核1G) 1.2 关闭selin ...

  5. 阿里云不支持stmp 的25端口,必须

    第一种方法 到阿里云解封25端口 特别注意阿里云的<25端口使用服务协议>:    我/我公司承诺并保证TCP 25端口仅用来连接第三方的SMTP服务器,从第三方的SMTP服务器外发邮件. ...

  6. JS实现多Div模块拖拽功能

    空闲时间,同事让帮忙整个JS拖拽div模块功能.于是便在网上搜索,总结如下一个可实现多div模块拖拽的功能.一下是整体的HTML代码, 里边可以控制到 拖拽开始(onStart),拖拽时候(onMov ...

  7. codeforces 380A Sereja and Prefixes (递归)

    题目: A. Sereja and Prefixes time limit per test 1 second memory limit per test 256 megabytes input st ...

  8. CSU 1554 SG Value (multiset/priority queue 思维题)

    题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1554 Description The SG value of a set (mult ...

  9. php面试专题---14、Linux基础考点

    php面试专题---14.Linux基础考点 一.总结 一句话总结: php考linux其实也考不了很难 1.系统定时任务? crontab命令和 at命令 crontab命令 crontab -e ...

  10. Getting Started Tutorial from msdn

    Getting Started Tutorial The topics contained in this section are intended to give you quick exposur ...