ChatGPT解决这个技术问题 Extra ChatGPT

Extension mysqli is missing, phpmyadmin doesn't work

I have a problem with phpmyadmin on ubuntu 12.04. I have already installed apache2, php5, mysql and phpmyadmin.

The phpinfo(); script, don't show nothing about mysqli or mysql extension.

When I try start phpmyadmin this error appear:

----
**phpMyAdmin - Error**
-------
**The mysqli extension is missing. Please check your PHP configuration.**
----

In the php.ini file, I uncommented extension=mysql.so line, but doesn't work...

Anyone have another posible solution?

Did you restart apache after uncommenting the line?
I feel some dumb after this.. :P Thanks Henry, i powered on my computer today and all work, thank you!
Restart the apache sudo /etc/init.d/apache2 restart
please close this issue if you get your answer
@HardikGajjar how can you close a question? Welcome to SO.

T
Timo

Latest phpMyAdmin versions require mysqli extension and will no longer work with mysql one (note the extra "i" at the end of its name).

For PHP 7.3

sudo apt-get install php7.3-mysqli

For PHP 8

sudo apt-get install php8.0-mysqli

Will install package containing both old one and the new one, so afterwards all you need to do is to add

extension=mysqli.so

in your php.ini, under the subject Dynamic Extensions.

Restart apache:

sudo systemctl restart apache2

Authenticate if needed and press enter.

Should be done! If problem still occurs remove the browser cache.


If the problem still re-occurs after this, clear your browser cache
Works for php7.4 as well, just use: sudo apt-get install php7.4-mysqli
What do you mean by authenticating in Authenitacate and press enter? The restart of apache2?
Guys, php8 is out since more than a year and there is not one entry mentioning php8. Welcome to SO. Package is php8.0-mysql.
@Timo Authenticate and press Enter, is for entering your password when Sudo prompts you to do it. And comment that the package version is outdated, in an answer from almost nine years,... just edit it.
H
Hardik Gajjar
sudo apt-get install php5-mysql
sudo apt-get install php5-mysqlnd 

try both of alternatively it works for me


My apt-get cannot find these packages. Does anyone know what repositories they are in?
actually php5 version deprecated from repo . please try this PPA from link askubuntu.com/questions/761713/…
@HardikGajjar That question is about downgrading to php5. Why not just install the php7.0 version? $ sudo apt-get install php7.0-mysql
@NealGokli In my case I have to php5, because I can't install php7.0-gd on Debian Jessie. It requires a too high version of libwebp5 that is not available through the apt. It used to work but since about half a year it's broken.
Can anyone explain Why this issue happens ? In my localhost it happens so many times.
N
Nilson Dimas

If you run PHPMyAdmin on localhost uncomment in file /etc/php5/apache2/php.ini this line:

mysqli.allow_local_infile = On

Restart Apache:

sudo /etc/init.d/apache2 restart

Thanks for this. This solution is used when the MySQLi extension is properly installed, but phpMyAdmin is running on localhost.
Works on PHP 7 as well (just note that the new php.ini location is /etc/php/7.0/apache2/php.ini).
J
Jost

Just restart the apache2 and mysql:

apache2: sudo /etc/init.d/apache2 restart

mysql: sudo /etc/init.d/mysql restart

then refresh your browser, enjoy phpmyadmin :)


It is really as trivial as that. The extension gets installed with phpmyadmin and needs a restart (apache, php5-fpm whatever). Many 'solutions' here do have the reload of the webserver as final step and in fact - in my opinion this is the only thing needed.
It really isn't as trivial as that. :-) You need to install the mysql/mysqli extension.
Far away in time, I asked this, never closed the topic. In fact, the first comment answered my question, but it's a comment, so I will take this as the correct answer.
M
Maanit

I tried a lot of the answers and none of them seemed to work because php7.0 is not the default.

sudo apt-get upgrade

seemed to do the job for me but I had to reinstall php7.0 and phpmyadmin after that:

sudo apt-get install php7.0 php7.0-mysql
sudo apt-get install apache2 apache2-mod-php7.0
sudo apt-get install phpmyadmin

Hope it helps!


Though you are small your answer is big. Helpful.
Z
Zegert

I faced same issue and resolved it by doing following steps:

First check PHP versions. If you have multiple PHP Versions. Suppose you have PHP versions like php7.0, php7.1 and php 7.2 then run these commands

For PHP7.0

sudo apt-get install php7.0-mysql
sudo apt-get install php7.0-mysqlnd 

For PHP7.1

sudo apt-get install php7.1-mysql
sudo apt-get install php7.1-mysqlnd 

For PHP7.2

sudo apt-get install php7.2-mysql
sudo apt-get install php7.2-mysqlnd 

For PHP7.3

sudo apt-get install php7.3-mysql
sudo apt-get install php7.3-mysqlnd

Edit the ini file and look for mysqli. Uncomment the line by removing ; for all php versions extension=mysqli.so

/etc/php//apache2/php.ini

For PHP7.0

sudo nano /etc/php/7.0/apache2/php.ini

For PHP7.1

sudo nano /etc/php/7.1/apache2/php.ini

For PHP7.2

sudo nano /etc/php/7.2/apache2/php.ini

For PHP7.3

sudo nano /etc/php/7.3/apache2/php.ini

and last restart apache server

sudo /etc/init.d/apache2 restart

S
Shimbawa

I solved this problem by editing /usr/local/zend/etc/php.ini.

(found it by doing netstat -nlp ¦ grep apache, then strace -p somepid ¦ grep php.ini).

At the end of the file, I added:

extension=/usr/lib/php5/20090626+lfs/mysql.so
extension=/usr/lib/php5/20090626+lfs/mysqli.so
extension=/usr/lib/php5/20090626+lfs/mcrypt.so

Adding it without the path did not work.

Then after a restart it worked.


R
Risheekant Vishwakarma

For ubuntu user open your terminal and type following command

sudo apt-get install mysql

After that just restart apache2 by typing this

sudo service apache2 restart 

refresh you browser and enjoy phhmyadmin


G
Giuseppe

For Ubuntu 20.04 users with php-fpm I fixed the issue by adding the full path in the php conf:

edit /etc/php/7.4/fpm/conf.d/20-mysqli.ini

and replace

extension=mysqli.so

with:

extension=/usr/lib/php/20190902/mysqli.so

This solution worked for me on Ubuntu 20.04 Desktop with PHP 7.4, PHP 8.0.7, MySQL 8.0.25 setup. What I did was edited /etc/php/7.4/apache2/php.ini and /etc/php/8.0/apache2/php.ini and replaced e lines as you said in both the files. Later restarted both, PHP and MySQL by sudo systemctl restart apache2 and sudo systemctl restart mysql.
k
kta

Checking the extension_dir is one of the thing you like to check from phpinfo().In my case it was extension_dir = "./" by default which was wrong. Change it to extension_dir = './ext/' or where all your extension dlls are currently residing.


I
Imad Ullah

Just add this line to your php.ini if you are using XAMPP etc. also check if it is already there just remove ; from front of it

extension= php_mysqli.dll

and stop and start apache and MySQL it will work.


M
MasterCassidy

You need the MySQLi module. This error usually occurs when manually installing phpMyAdmin.

sudo apt-get install php7.3-mysql

It will return you with.

[Creating config file /etc/php/7.3/mods-available/mysqlnd.ini with new version]

[Creating config file /etc/php/7.3/mods-available/mysqli.ini with new version]

Then.

sudo service apache2 restart.

Then.

Press F5 on your browser.

E
Echilon

This worked for me , make a database with a php and mysql script and open up the mysql console and type in create user 'yourName'@'127.0.0.1' and then type in grant all privileges on . to 'yourName'@'127.0.0.1' then open up a browser go to localhost and a database should been made and then go to your phpmyadmin page and you will see it pop up there.


T
Tamil Selvan C

at ubuntu 12.04 i had to change mssql.compatability_mode = On. put On and works


Where do you change this?
G
Golgot

Since I had this problem following an upgrade, I just disable Apache2-php5

a2dismod php5

and activated php7

a2enmod php7

Hope it may help anybody!


M
Mike Araya

I have encountered the same error on ubuntu and what worked for me was editing 2 lines in /etc/php/7.3/apache2/php.ini

  ;extension=mysqli to   extension=mysqli

and gave the extension variable location to mysqli.so after uncommenting it

   extension=/usr/lib/php/20170718/mysqli.so

then restart the service just to make sure

systemctl start mysql

S
SergeantSerk

For the record, my system is Ubuntu Server 20.04 and none of the solutions here worked. For me, I installed PHP 7.4 and I had to edit enter code here/etc/php/7.4/apache2/php.ini`.

Within this, search for ;extension=mysqli, uncomment and change mysqli to mysqlnd so it should look like this extension=mysqlnd. I tried using mysqli but I faced the same error as if I didn't enable it but mysqlnd worked for me.


G
Green Joffer

Had the very same problem, but in my case the reason was update of Ubuntu and php version - from 18.04 and php-7.2 up to 20.04 and php-7.4.

The Nginx server was the same, so in my /etc/nginx/sites-available/default was old data:

server {
  location /pma {
    location ~ ^/pma/(.+\.php)$ {
      fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    }
  }
}

I could not get phpmyadmin to work with any of php.ini changes and all answers from this thread, but at some moment I had opened the /etc/nginx/sites-available/default and realised, that I still had old version of php. So I just changed it to

fastcgi_pass unix:/run/php/php7.4-fpm.sock;

and the issue was gone, phpmyadmin magically started to work without any mysqli-file complaint. I even double checked it, but yeap, that's how it works - if you have wrong version for php-fpm.sock in your nginx config file, your phpmyadmin will not work, but the shown reason will be 'The mysqli extension is missing'


A
Avinash

I hope my successful answer helps someone in recent times as I had to try many mix-and-matches and then found it:

This solution worked for me on Ubuntu 20.04 Desktop with PHP v7.4, PHP v8.0.7 and MySQL v8.0.25 setup.

What I did was edited /etc/php/7.4/apache2/php.ini and /etc/php/8.0/apache2/php.ini files and replaced extension=mysqli.so with extension=/usr/lib/php/20190902/mysqli.so in both the files.

Later, restarted both of these (PHP and MySQL) by sudo systemctl restart apache2 and sudo systemctl restart mysql. Refreshed Chrome, and phpMyAdmin responded with the login screen.

(UPDATE: Please check if you have /usr/lib/php/20200930/mysqli.so file as well. I tested this as it looked newer by directory date, and this too worked in both the PHP files as extension=/usr/lib/php/20200930/mysqli.so)