- 首先确定是
mysql_connect()
和mysql_pconnect()
的问题,故障现象就是函数返回空,而mysql_error()
返回“No such file or directory”。 - 写个phpinfo页面,找到
mysql.default_socket
、mysqli.default_socket
、pdo_mysql.default_socket
。 - 启动mysql(见说明2),执行命令 STATUS; 记下UNIX socket的值。
- 如果2和3的值不一样,则打开php.ini(可以从phpinfo页面中找到php.ini的位置,默认是
/private/etc/php.ini
),将2中提到的三个配置项的值改成3的值。(注意,一共修改三处,分别为:
mysql.default_socket
、mysqli.default_socket
、pdo_mysql.default_socket
) - 重启apache。
OK,到这里错误就排除了。
相关文章
- 12-31git提交报错:The file will have its original line endings in your working directory
- 12-31<command-line>:0:12: fatal error: curses.h: No such file or directory 报错解决方法
- 12-31tar 解压bz2报错 Cannot exec: No such file or directory
- 12-31xmanager运行报错:bash: /usr/bin/xterm: No such file or directory
- 12-31【Git远程协作】Pull Request成功,并解决报错error: cannot spawn sh: No such file or directory
- 12-31Git报错 error: cannot spawn more: No such file or directory
- 12-31解决liblapack.so.3: cannot open shared object file: No such file or directory报错
- 12-31qt+opencv 构建项目时报错——no such file or directory
- 12-31安装Yellowfin报错——No such file or directory: '/tmp/pip-build-jykvuD/YellowFin/README.md'
- 12-31mlflow ui 启动报错No such file or directory: 'gunicorn': 'gunicorn'