mac 连接mysql的时候提示

Warning: mysqli::real_connect(): (HY000/2002): No such file or directory

[说明1]MAC下MYSQL的安装路径:/usr/local/mysql-5.5.28-osx10.6-x86

数据库的数据文件在该目录的data文件夹中;

命令文件在bin文件夹中。

[说明2]通过终端打开MYSQL命令行的方法:/usr/local/mysql-5.5.28-osx10.6-x86/bin/mysql

好下面说一下连接MYSQL数据库时报错的解决办法。

1,首先确定是mysql_connect()和mysql_pconnect()的问题,故障现象就是函数返回空,而mysql_error()返回“No such file or directory”

2,写个phpinfo页面,找到mysql.default_socket、mysqli.default_socket、pdo_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_socket、mysqli.default_socket、pdo_mysql.default_socket)

5,重启apache

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

mac 连接mysql提示 Warning: mysqli::real_connect(): (HY000/2002): No such file or directory的更多相关文章

  1. 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. 无法登录 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 ...

  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. [PDOException] SQLSTATE[HY000] [2002] No such file or directory

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

  5. 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 ...

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

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

  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. 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 ...

  9. 【不积跬步,无以致千里】安装roundcube 时出现 “DSN (write): NOT OK(SQLSTATE[HY000] [2002] No such file or directory)”

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

随机推荐

  1. Java中List、Collections实现梭哈游戏

    package ch8; import java.util.*; /** * Created by Jiqing on 2016/11/27. */ public class ShowHand { / ...

  2. C10K及C100K问题探讨 & 怎么应对大流量大并发

    首先开宗明义,离开业务单独讨论并发,都是扯淡. 就像 https://www.zhihu.com/question/20493166/answer/15998053 这里面说的 谈并发必然要谈业务,空 ...

  3. Mysql的一些小知识点

    MySQL简介:是由瑞典的MySQL AB公司开发的,目前是Oracle(甲骨文)公司扥一个关系型数据库产品(2008年MySQL AB公司被Sun公司收购,2009年Sun公司又被 Oracle公司 ...

  4. x265

    1.编译库 https://bitbucket.org/multicoreware/x265/src/tip/build/README.txt?at=default 2.无法定位程序输入点x265_e ...

  5. Animation用法

    测试代码及说明: <!DOCTYPE html> <html lang="en-US"> <head> <meta charset=&qu ...

  6. on delete cascade 和on update cascade

    这是数据库外键定义的一个可选项,用来设置当主键表中的被参考列的数据发生变化时,外键表中响应字段的变换规则的.update 则是主键表中被参考字段的值更新,delete是指在主键表中删除一条记录:on ...

  7. mac app icon 设置

    mac app icon 设置 1:目前 mac app 所需要的icon 图标尺寸 icon_16x16.png 16px icon_16x16@2x.png 32px icon_32x32.png ...

  8. 5.3.2 Eclipse集成开发环境的使用技巧

    Eclipse具有强大的编辑.调试.编译和打包功能,本节仅讲解Eclipse中最常用的功能. 1.将程序代码和注释字体变大 (1)启动Eclipse,选择“Windows”->“Preferen ...

  9. 重启Apache报错apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName ... waiting的解决方法

    启动apache提示 : apache2: Could not reliably determine the server's fully qualified domain name, using 1 ...

  10. cf(#div1 B. Dreamoon and Sets)(数论)

    B. Dreamoon and Sets time limit per test 1 second memory limit per test 256 megabytes input standard ...