Can not activate php-mysql with MariaDB on Ubuntu 23.10

I upgraded my Ubuntu to version 23.10. This comes with PHP 8.2. I installed MariaDB and php-mysql extension from standard Ubuntu repository.

sudo apt install php libapache2-mod-php php-mysql mariadb-server

MariaDB works well through CLI client, but PHP does not communicate with the database.

My local WordPress installations return this error message:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

Please check that the mysqli PHP extension is installed and enabled.

I found this info:
PHP 8.2: MySQLi can no longer be compiled with libmysqli

Could this be the cause? Is there any way to activate MySQL Native Driver in Ubuntu’s PHP 8.2?

Update: temporarily resolved by downgrade to PHP 8.1 from ppa:ondrej/php.

Asked By: Robert Zelník


What you have described works without problems on a clean freshly installed Ubuntu 23.10. It looks like you broke something while experimenting with ppa:ondrej/php. Ondrej’s repo only supports LTS releases, so it will not work with Ubuntu 23.10.

My suggestion is to do some cleanup and reinstall your PHP and required packages.

  1. Remove ppa:ondrej/php:

    sudo add-apt-repository --remove ppa:ondrej/php
  2. Remove the PHP:

    sudo apt purge php*
    sudo apt autoremove
    sudo rm -rf /etc/php/8.2
    sudo rm -rf /usr/lib/php
  3. Install PHP:

    sudo apt install php php-mysql
    sudo service apache2 restart
Answered By: sotirov
Categories: Answers Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.