Blogger Information
Blog 29
fans 0
comment 0
visits 46604
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Mac下php连接MySQL报错"no directory"的解决办法
盼盼love的博客
Original
971 people have browsed it

本文转自:http://blog.sina.com.cn/s/blog_6f72ff900101aonx.html

本来准备安装sqli-labs,但是配置好apache后总是报错("No directory"),百度一下发现是默认路径不对

Mac下MySQL的安装路径(我的MySQL是使用homebrew安装的):/usr/local/Cellar/mysql/5.7.18_1

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

命令文件在bin文件夹中。

通过终端打开MySQL命令行的方法:/usr/local/Cellar/mysql/5.7.18_1/bin/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

phpinfo中的信息如下:<?php phpinfo(); ?>

3,启动mysql(mysql -u root - p),执行命令 STATUS; 记下UNIX socket的值

6.png

4,如果2和3的值不一样,则打开php.ini(可以从phpinfo页面中找到php.ini的位置,默认是/private/etc/php.ini),将2中提到的三个配置项的值改成3的值。

5.png

三个地方都要改成mysql中UNIX socket的值,三个地方是:mysql.default_socket、mysqli.default_socket、pdo_mysql.default_socket

5,重启apache

4.png

sudo apachectl -k restart

然后再打开sqli-labs,发现问题已经解决了!!!



链接:https://www.jianshu.com/p/be3e89a3cf12



Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post