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. B/S上传整个文件夹

    在web项目中上传文件夹现在已经成为了一个主流的需求.在OA,或者企业ERP系统中都有类似的需求.上传文件夹并且保留层级结构能够对用户行成很好的引导,用户使用起来也更方便.能够提供更高级的应用支撑. ...

  2. 求超大文件上传方案( Java )

    最近遇见一个需要上传百兆大文件的需求,调研了七牛和腾讯云的切片分段上传功能,因此在此整理前端大文件上传相关功能的实现. 在某些业务中,大文件上传是一个比较重要的交互场景,如上传入库比较大的Excel表 ...

  3. BZOJ 1597: [Usaco2008 Mar]土地购买 动态规划 + 斜率优化

    Code: #include<bits/stdc++.h> #define maxn 1000000 #define ll long long #define x(i) (b[i+1]) ...

  4. KMP字符串匹配模板

    题目描述 如题,给出两个字符串s1和s2,其中s2为s1的子串,求出s2在s1中所有出现的位置. 为了减少骗分的情况,接下来还要输出子串的前缀数组next. (如果你不知道这是什么意思也不要问,去百度 ...

  5. 约瑟夫环 c++ 循环输入

    #include<iostream> #include<string.h> #include<cstdio> #include <sstream> us ...

  6. 字符串(一):char 数组

    字符串使用方法整理 系列: 字符串(一):char 数组 字符串(二):string 1. 声明 如下是一个例子(=> 表示表达式等价): char a[20] = "abcd&quo ...

  7. vue里面的this指向

    this.$http.jsonp(api).then(function(response){ console.log(response); console.log(this); this.list=r ...

  8. vue.js + element 搭建后台管理系统 笔记(一)

    此文仅记录本人在搭建后台系统过程中遇到的难点及注意点,如果能帮到各位自然是极好的~~~ 项目主要架构:vueJS.elementUI.scss 一.项目初始化 首先需要安装nodejs,安装方法就不在 ...

  9. Vagrant 手册之 Provisioning - File

    原文地址 Provisioner 名字:"file" Vagrant 的 file provisioner 允许将文件或目录从主机上传到客户机. File provisioning ...

  10. C++输出字符指针指向的地址

    int main() { char *s2 = "jwdajkj"; ]; )); printf("%p,%p\n", s3, s1); cout <&l ...