首页 > 数据库技术 > 详细

mac 连接mysql提示 mysqli::real_connect(): (HY000/2002): No such file or directory

时间:2017-02-19 00:04:30      阅读:434      评论:0      收藏:0      [点我收藏+]

1.首先登录MySQL命令行,查看unix socket所在目录。

 

mysql> STATUS

--------------

/usr/local/mysql/bin/mysql  Ver 14.14 Distrib 5.7.15, for osx10.11 (x86_64) using  EditLine wrapper

 

Connection id: 2

Current database: todo_list

Current user: root@localhost

SSL: Not in use

Current pager: stdout

Using outfile: ‘‘

Using delimiter: ;

Server version: 5.7.15 MySQL Community Server (GPL)

Protocol version: 10

Connection: Localhost via UNIX socket

Server characterset: latin1

Db     characterset: latin1

Client characterset: utf8

Conn.  characterset: utf8

UNIX socket: /tmp/mysql.sock

Uptime: 10 hours 53 min 25 sec

 

2. 根据phpinfo()查看 PHP.ini的目录和找到mysql.default_socket、mysqli.default_socket、pdo_mysql.default_socket的所在目录。mac下php.ini默认的目录是/private/etc/php.ini.

    若mysql.default_socket、mysqli.default_socket、pdo_mysql.default_socket的值不是步骤1中的/tmp/mysql.sock,则修改php.ini中的mysql.default_socket、mysqli.default_socket、pdo_mysql.default_socket值为 /tmp/mysql.sock

 

若/private/etc/php.ini不存在,则复制一个

cp /private/etc/php.ini.default /private/etc/php.ini

 

3. 重启apache

sudo apachectl restart

 

 

reference: http://www.cnblogs.com/whlives/p/4495106.html

mac 连接mysql提示 mysqli::real_connect(): (HY000/2002): No such file or directory

原文:http://www.cnblogs.com/ganghuige/p/6414458.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!