Search code examples
phpcodeignitermysqlimampbitnami

Cant execute command line with codeigniter 3 mysql_init() error


I want to test PHP script that will execute a command line command. But I get the following error in the shell.

The site that I've design locally works perfectly

Fatal error: Call to undefined function mysqli_init() in /Applications/mampstack-5.6.19-0/frameworks/codeigniter/system/database/drivers/mysqli/mysqli_driver.php on line 136

A PHP Error was encountered

Severity:    Error
Message:     Call to undefined function mysqli_init()
Filename:    /Applications/mampstack-5.6.19-0/frameworks/codeigniter/system/database/drivers/mysqli/mysqli_driver.php
Line Number: 136

Backtrace:

I'm using Bitnami MAMP Stack 5.6.19.0 with Codeigniter 3.0


Solution

  • You need activate the php_mysqli extension in the php.ini file that controls the PHP CLI, its not the same one as controls PHP Under the web server.

    From the terminal do

    php -i
    

    And look for the parameter Loaded Configuration File and Configuration File (php.ini) Path that will tell you which php.ini file to amend and where it lives.

    If one does not exist, as I believe is the case on some installs, then you know where to create one by looking at the Configuration File (php.ini) Path parameter.

    You could start by copying your web server version into this directory, but do a quick sanity check on it as well