php 连接数据库 Warning: mysqli_connect(): (HY000/2002): No such file or directory in
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的更多相关文章
- 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 ...
- TP连接数据库报错:SQLSTATE[HY000] [2002] No such file or directory
连接数据库报错:“SQLSTATE[HY000] [2002] No such file or directory”. 出现这个问题的原因是PDO无法找到mysql.sock或者mysqld.soc ...
- 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 ...
- 无法登录 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 ...
- [PDOException] SQLSTATE[HY000] [2002] No such file or directory
编译安装PHP7之后,在安装mysql之后,用pdo操作数据库的时候,出现了此错误[PDOException] SQLSTATE[HY000] [2002] No such file or direc ...
- 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 ...
- Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory
执行下面的代码报错: $pdo = new PDO('mysql:dbname=db_test;host=localhost', 'root', '123456'); PHP Fatal error: ...
- YII 错误 SQLSTATE[HY000] [2002] No such file or directory
在使用yii的yii\db\Connnection时发生错误 <?php namespace app\controllers; use yii\web\Controller; use yii\d ...
- 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 ...
随机推荐
- 基于ELK Stack7.1.0构建多用户安全认证日志系统
配置tls加密通信及身份验证,主要目的是为了确保集群数据安全.在es早期版本,安全认证相关功能都属于商业付费服务,一般普通公司如果集群部署在内网,基本上就忽略了这些安全认证,当然也可以通过Ngin ...
- Android逆向之旅---解析编译之后的Dex文件格式
一.前言 新的一年又开始了,大家是否还记得去年年末的时候,我们还有一件事没有做,那就是解析Android中编译之后的classes.dex文件格式,我们在去年的时候已经介绍了: 如何解析编译之后的xm ...
- Eclipse中安装和使用FindBugs
FindBugs在Eclipse的离线安装: 1 到http://findbugs.sourceforge.net/downloads.html下载20131115123549_nlpir_ict ...
- centos 无界面安装selenium+chrome+chromedirver的设置
配了一中午的,好不容易正好记录下. 1.我的centos的位数 输入rpm -q centos-release 结果:centos-release-7-4.1708.el7.centos.x86_64 ...
- 定义一个JobService,开启本地服务和远程服务
@SuppressWarnings(value = ["unchecked", "deprecation"])@RequiresApi(Build.VERSIO ...
- custom serializer for just one property in Json.NET
Json序列化的时候跳过加密字段 字段类定义如下 public class Field { public bool IsEncrypted { get; set; } public string Na ...
- Linux 用户和组信息
linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号.在使用linux操作系统时候,通常我们会遇到对多用户进行管理.比如: 用户账号的添加. ...
- ajax跨域处理 No 'Access-Control-Allow-Origin' header is present on the requested resource 问题
Controller层的类上增加@CrossOrign注解,当前文件的所有接口就都可以被调用 spring注解@CrossOrigin不起作用的原因 1.是springMVC的版本要在4.2或以上版本 ...
- The server time zone value 'EDT' is unrecognized or represents more than one time zone
解决: (1)使用 server mysql start命令启动mysql (2)在mysql中执行show variables like '%time_zone%'; (3)输入select now ...
- HTML--JS 二级联动
<!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...