PHP连接MYSQL 报错"No such file or directory"

    1. 首先确定是mysql_connect()mysql_pconnect()的问题,故障现象就是函数返回空,而mysql_error()返回“No such file or directory”。
    2. 写个phpinfo页面,找到mysql.default_socketmysqli.default_socketpdo_mysql.default_socket
    3. 启动mysql(见说明2),执行命令 STATUS; 记下UNIX socket的值。
    4. 如果2和3的值不一样,则打开php.ini(可以从phpinfo页面中找到php.ini的位置,默认是/private/etc/php.ini),将2中提到的三个配置项的值改成3的值。


      (注意,一共修改三处,分别为:mysql.default_socketmysqli.default_socketpdo_mysql.default_socket
    5. 重启apache。

      OK,到这里错误就排除了。

时间: 2024-08-13 02:50:22

PHP连接MYSQL 报错"No such file or directory"的相关文章

连接mysql报错:error 2003 (hy000):can't connect to mysql server on 'localhost' (10061)

一.mysql 的bin目录下有个MySQLInstanceConfig.exe,运行就可以进行创建数据库实例,创建实例时也可以生成windows 服务,把服务设置成自动启动就可以了 二.安装在D盘的discuzz!打开后出现上述错误,请问应如何处理?winmysqladmin已经启动,但三色树上有一个小红点如果出现"ERROR 2003: Can't connect to MySQL server on 'localhost' (10061)",说明你的MySQL还没有启动.解决办法

PHP连接MySQL报错:SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket 'MySQL' (2)

如下所示,PHP连接MySQL报错: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket 'MySQL' (2) 测试代码如下: <?php try { $dsn = 'mysql:dbname=php-note;host=localhost;port=3306;charset=utf8'; $username = 'root'; $password = 'root'; new PDO( $dsn,

jdbc连接mysql报错:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column &#39;&#233;?‘&#229;?‰&#230;—&#173;&#39; in &#39;field list&#39;

解决了中文显示乱码问题之后,又出现了这么一个问题, 思考一下,这绝对是输入文本的问题. 试了一下,果然不出所料. 再次怀疑编码,没有办法, 只有很无奈地去百度了,结果是与编码没有问题啊. sql.execute("insert into reader values('"+rn+"','"+pid+"','"+tele+"','"+kno+"')"); 原来报错是因为我没写单引号,mysql当然不认识啊.OK

1130 - Host&#39;xxx.xxx.xxx.xxx&#39; is not allowed to connect to this MySQL server解决Navicat连接MySQL报错

最近使用Navicat for MySQl访问远程mysql数据库,出现报错,显示"1130 - Host'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server".解决办法如下: 方法/步骤 首先看报错窗口. 经查阅,错误原因是:本地IP(xxx.xxx.xxx.xxx)没有访问远程数据库的权限. 于是下面开启本地IP(xxx.xxx.xxx.xxx)对远程mysql数据库的访问权限. 首先远程连接进入服务器,在

连接mysql报错Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: YES)解决办法

1.打开MySQL目录下的my.ini文件,在文件的最后添加一行"skip-grant-tables"(免密码登录),保存并关闭文件,重启MySQL服务. 2.通过命令行进入MySQL的BIN目录,输入"mysql -u root -p"(不输入密码),回车即可进入数据库. 3.执行"use mysql;",使用mysql数据库. 4.修改密码:执行" update MySQL.user set authentication_strin

用Navicat连接mysql报错:2003-Can&#39;t connect to MySql server on &#39;10.100.0.109&#39;(10039)

问题描述 在 window 系统上,用 Navicat 连接 Mysql 数据库,弹出以下提示 问题原因  Mysql 数据库未启动 解决方案:启动 Mysql 数据库 1.点击桌面左下角运行 cmd,然后回车 2.输入命令:services.msc,然后回车,弹出服务页面 3.在服务页面找到 MySQL服务,查看状态,如果未启动,就启动服务 用Navicat连接mysql报错:2003-Can't connect to MySql server on '10.100.0.109'(10039)

连接mysql报错 : The server time zone value &#39;&#214;&#208;&#185;&#250;&#177;&#234;&#215;&#188;&#202;&#177;&#188;&#228;&#39; is unrecognized or represents more than one time zone...

time zone 时区错误 DBEAVER连接MySQL运行报错The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone... 使用root用户登录mysql,执行以下语句 show variables like '%time_zone%'; 执行结果是这样的: SYSTEM为SQL默认美国时间,而我们中国要比他们迟8小时 因此将时区设置为当前系统时区即可,所以

连接mysql报错java.sql.SQLException: The server time zone value &#39;?й???????&#39; is unrecognized...解决方法

报错内容: java.sql.SQLException: The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time

Django2.2连接MySQL报错Authentication plugin &#39;caching_sha2_password&#39; cannot be loaded

之前在升级网站的时候,runserver遇到了Authentication plugin 'caching_sha2_password' cannot be loaded的报错.百度过后知道是因为MySQL8采用了caching_sha2_password的加密方式,需要改回旧的mysql_native_password,在此附上修改方法: mysql -u root -p password >ALTER USER 'root'@'localhost' IDENTIFIED BY 'passwo