调用未定义的mysqli_connect()函数.调用PHP脚本时


Ubuntu PHP Fatal error: Call to undefined function mysqli_connect() in.. when calling PHP script

我运行Ubuntu桌面14.04 LTS (Trusty Tahr),我试图设置Apache 2, MySQL服务器和PHP,但我一直得到以下错误:

PHP致命错误:调用未定义函数mysqli_connect()

我所做的是在正确的php.ini:

取消:

扩展= msqli.so

设置从phpinfo()获取的路径:

extension_dir = "./usr/lib/php5/20121212+lfs"

为什么连接数据库的mysqli函数仍然没有定义?

通常建议运行更新

sudo apt-get update

然后安装所需版本

sudo apt-get install php5-mysql
sudo apt-get install php7.0-mysql
sudo apt-get install php7.1-mysql
sudo apt-get install php7.2-mysql

重新启动apache

sudo service apache2 restart

在我的情况下,php5-mysql在我的Ubuntu服务器上丢失了。安装包后,它可以很好地与mysqli适配器一起工作。

sudo apt-get install php5-mysql

它解决了我的CodeIgniter 3.0 mysqli连接有效