drsqpko5286 2016-07-26 00:21 采纳率: 0%
浏览 32

Mysqli连接在shell中失败并且在apache(macports)中运行良好

I hope you are fine today. I have a weird problem. I recently changed my web apps to use mysqli to connect to mysql instead of mysql_connect. When server by apache, everything goes fine and queries are sent properly.

However, when executing php scripts in the terminal, I get the following error:

Error 2002: No such file or directory

I checked the socket files in the php56/php.ini, and the socket is properly declared.

mysqli.default_socket=/opt/local/var/run/mysql55/mysqld.sock

However, in shell, php socket is wrong. Somehow the socket path changes from apache to the terminal php environment and I am completely lost. What php.ini configuration file is usin

me@MacBook-Pro /Users/me/www$ php -i | grep mysqli
mysqli
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
API Extensions => mysqli,pdo_mysql,mysql

Inside the shell, the configuration file is not properly addressed. Why?

me@MacBook-Pro /Users/me/www$ php -i | grep ini
Configuration File (php.ini) Path => /etc

However, when served by apache the ini file and socket are fine.

Please help :-P I am using macports on macosx. Thanks!

  • 写回答

1条回答 默认 最新

  • dstbtam8732 2016-07-26 00:33
    关注

    Ok guys I got around the problem creating a symlink to the real php.ini from /etc/php.ini. Not a fix, but works.

    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据