简体   繁体   English

PHP的内置Web服务器出现mysqli_connect()错误

[英]mysqli_connect() error with PHP's built-in web server

I compiled PHP with mysqlnd using the prescriptions from Mysqlnd installation . 我使用Mysqlnd安装中的规定用mysqlnd编译了PHP。 PHP works fine. PHP可以正常工作。 php -m | grep mysql php -m | grep mysql shows that neccessary MySQL modules are actually installed. php -m | grep mysql显示实际上已经安装了必要的MySQL模块。 Then I run php -S localhost:8088 -t <dir>. 然后我运行php -S localhost:8088 -t <dir>. In PHP code function_exists('mysqli_connect') does return true . 在PHP代码中, function_exists('mysqli_connect')确实返回true But when I run mysqli_connect() warning mysqli_connect(): (HY000/2002): No such file or directory arises. 但是,当我运行mysqli_connect()警告mysqli_connect(): (HY000/2002): No such file or directory In /etc/php.ini I set default socket to /tmp/mysql.sock then to /var/lib/mysql/mysql.sock . /etc/php.ini我将默认套接字设置为/tmp/mysql.sock然后设置为/var/lib/mysql/mysql.sock Both variants didn't work. 两种变体均无效。 How can I enable mysql support in PHP-built-in server? 如何在PHP内置服务器中启用mysql支持?

Have you tried those solutions ? 您是否尝试过这些解决方案? Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in 警告:mysql_connect():[2002]中没有这样的文件或目录(试图通过unix:///tmp/mysql.sock连接)

First try to use 127.0.0.1 instead of "localhost" in your mysqli_connect call. 首先尝试在mysqli_connect调用中使用127.0.0.1而不是“ localhost”。

Then make sure there is sockets where it should : make a symbolic link from /tmp/mysql.sock to /var/mysql/mysql.sock (or other way depending what exists on your computer) 然后确保在应有的套接字处:建立从/tmp/mysql.sock到/var/mysql/mysql.sock的符号链接(或其他方式,取决于计算机上的内容)

Finally try to read all answers listed in the link above, maybe one of them will hel you 最后尝试阅读上面链接中列出的所有答案,也许其中一个会帮助您

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM