php的mysqli_connect函数显示 No such file or directory错误以及localhost换成127.0.0.1执行成功
Centos7环境-php7-MariaDB5.5.60
(新安装的php7,执行php -m 显示有mysqli模块,php.ini没有改其它)
测试代码为:
<?php
//~ echo date('Y-m-d H:i:s',time());
$link_id = mysqli_connect('localhost','root','');
if($link_id)
{
echo 'ok';
}
else
{
echo mysqli_connect_error();
}
?>
网页运行时显示 No such file or directory 错误
把参数 'localhost' 换成 ‘127.0.0.1’ 后 显示 ok,即执行成功!如果想使用 ‘localhost' 这个参数
如果是新安装的MariaDB,一定要先执行
mysql_secure_installation
根据提示安装完成之后,再运行上述代码正常情况下就运行成功了。如果还显示错误再参考下面
解决方法为:
找到 /etc/my.cnf 文件(我的是在这个位置,具体根据自己的机器)
找到这一行:
然后找到 /etc/php.ini
找到这一行:
默认情况下为空,把它修改为上述路径就可以了(不用加引号)
重新启动php-fpm
使用 ’localhost' 参数,刷新网页显示 'ok',即运行成功
参考:【故障】php链接mysql数据库,使用localhost一直显示错误,当使用127.0.0.1l链接正常,故障记录
php的mysqli_connect函数显示 No such file or directory错误以及localhost换成127.0.0.1执行成功的更多相关文章
- php 连接mysql 主机 localhost,显示 No such file or directory
打开 php.ini文件,找到这1行 mysql.default_socket 然后将它修改为 mysql.default_socket=/path/to/mysql.sock /path/to/my ...
- /etc/rc.d/init.d/iptables: No such file or directory 错误原因
注:本文转载自cnblogs:一天学点的文章</etc/rc.d/init.d/iptables: No such file or directory 错误原因> RedHat Enter ...
- mkdir()提示No such file or directory错误的解决方法
转自:http://www.02405.com/program/php/1692.html 在php中使用mkdir()方法创建文件夹时报错:No such file or directory,出错代 ...
- Linux运行shell脚本提示No such file or directory错误的解决办法
Linux执行.sh文件,提示No such file or directory的问题: 原因:在windows中写好shell脚本测试正常,但是上传到 Linux 上以脚本方式运行命令时提示No s ...
- python打包成.exe工具py2exe0-----No such file or directory错误
转自:http://justcoding.iteye.com/blog/900993 一.简介 py2exe是一个将python脚本转换成windows上的可独立执行的可执行程序(*.exe)的工具, ...
- 执行Python "/bin/usr/python: bad interpreter: No such file or directory" 错误
今天在电脑上写了一个Python脚本,写好之后用ftp传上去,然后执行/var/www/cron.py,结果报错,/bin/usr/python: bad interpreter: No such f ...
- Mysql_connect报告”No such file or directory”错误的解决方法
写了个php脚本单独执行mysql_connect(),发现错误信息居然是“No such file or directory"! 首先确定是mysql_connect()和mysql_pc ...
- find: `./folder': No such file or directory 错误处理
这是我正在处理的目录的内容: misha@hp-laptop:~/work/c/5$ ls -l total 8 -rw-rw-r-- 1 misha misha 219 May 20 15:37 d ...
- 解决openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory错误
问题 在Centos7上编译安装openssl后,运行openssl version出现如下错误: openssl: error while loading shared libraries: lib ...
随机推荐
- C# 后台添加Log信息
我们在做项目的时候,经常会使用到Log日志,今天分享一下如何在后台添加Log信息 创建一个写Log的方法: public void WriteLog(string Action) { try { st ...
- 4类Storage方案(AS开发实战第四章学习笔记)
4.1 共享参数SharedPreferences SharedPreferences按照key-value对的方式把数据保存在配置文件中,该配置文件符合XML规范,文件路径是/data/data/应 ...
- C/C++内存管理详解 ZZ
内存管理是C++最令人切齿痛恨的问题,也是C++最有争议的问题,C++高手从中获得了更好的性能,更大的自由,C++菜鸟的收获则是一遍一遍的 检查代码和对C++的痛恨,但内存管理在C++中无处不在,内存 ...
- 读取本地IP地址和子网页码
#region 读取本地IP地址和子网页码 //读取本地IP地址和子网页码 NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterf ...
- 【MyBatis】 MyBatis入门
1.MyBatis简介 MyBatis是这个框架现在的名字,而此框架最早的名字是IBatis,其名字的含义是“internet”.“abatis”两个单词的组合,是在2002年的时候开始的一个开源项目 ...
- MySQL 数据库 -- 数据操作
数据的增删改 一 介绍 MySQL数据操作: DML ======================================================== 在MySQL管理软件中,可以通过 ...
- fill & stroke
- (void)stroke Draws a line along the receiver’s path using the current drawing properties. - (void) ...
- Redis命令、数据结构场景、配置文件总结
本文大纲 一.常用数据类型简介二.redis操作命令三.redis配置文件详解四.redis数据类型使用场景 一.常用数据类型简介 redis常用五种数据类型:string,hash,list,set ...
- 2018-2019-2 网络对抗技术 20165322 Exp5 MSF基础应用
2018-2019-2 网络对抗技术 20165322 Exp5 MSF基础应用 目录 实验内容与步骤 一个主动攻击实践 MS08-067(失败) ms17_010_psexec(成功且唯一) 一个针 ...
- TP框架---Model模型层---做模型对象
TP框架----Model模型层---------------做模型对象 Model模型层是用来做什么的呢???? 主要是用来做操作数据库访问的. 也就说明TP框架自带了一种访问数据库的方式,使用的是 ...