max
max

Reputation: 31

php suddenly thrown error "The mysqli extension is missing. Please check your PHP configuration. See our documentation for more information."

I was setting up a site and everything was working fine suddenly my php thrown an error

The mysqli extension is missing. Please check your PHP configuration. See our documentation for more information.

When i type php --version i get response :

PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli.so' (tried: /usr/lib/php/20170718/mysqli.so (/usr/lib/php/20170718/mysqli.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/mysqli.so.so (/usr/lib/php/20170718/mysqli.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

and for mysql --version response is :

mysql  Ver 14.14 Distrib 5.7.24, for Linux (x86_64) using  EditLine wrapper

My ubuntu version is 18.04. What can be gone wrong ? Please help. I didnt do any upgrade or install

and my extensions in php.ini is

;extension=bz2
;extension=curl
;extension=fileinfo
;extension=gd2
;extension=gettext
;extension=gmp
;extension=intl
;extension=imap
;extension=interbase
;extension=ldap
;extension=mbstring
;extension=exif      ; Must be after mbstring as it depends on it
;extension=mysqli.so
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
;extension=odbc
;extension=openssl
;extension=pdo_firebird
;extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
;extension=pdo_sqlite
;extension=pgsql
;extension=shmop

; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=snmp

;extension=soap
;extension=sockets
;extension=sqlite3
;extension=tidy
;extension=xmlrpc
;extension=xsl

Upvotes: 1

Views: 1493

Answers (3)

inquam
inquam

Reputation: 12932

The error is very self-explanatory. Your system is not configured to have mysqli enabled. You have to make sure the extension is installed and enabled correctly.

To install mysqli if it's missing

sudo apt-get install php-mysql

For Ubuntu I seem to remember your are not advised to edit the php.ini directly but instead use phpenmod to enable modules.

Example

phpenmod mysqli

To check mysqli setting in PHP you can run something like

php -r 'phpinfo();' | grep -i mysqli

Upvotes: 2

Manish Shukla
Manish Shukla

Reputation: 1365

you just need to uncomment following line ;extension=mysqli.so in php.ini

To uncomment this line just remove initial (;) from the line. save ini file and restart server. it should work

Upvotes: 1

Kiran Patel
Kiran Patel

Reputation: 379

Install one of the packages that contain your package. Pick the latest:

Also, when installing a package, make sure your libraries are updated with these commands:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install php7.2-mysql

here is some examples for php packages

apt-get install php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml

Upvotes: 1

Related Questions