PHP installation missing MySQL extension required by Wordpress

Issue Summary

trying to use wp cli in the localwp site shell but running into

“Error: 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.”

Troubleshooting Questions

  • Does this happen for all sites in Local, or just one in particular?
    yes, every site I’ve tried to import or create from new.

  • Are you able to create a new, plain WordPress site in Local and access it in a Browser?



System Details

  • Which version of Local is being used?

  • What Operating System (OS) and OS version is being used?

Arch Linux/Garuda Linux

  • Attach the Local Log. See this Help Doc for instructions on how to do so: (23.0 KB)

Hi @dolldothouse

So when you spin a site up are you always using PHP 7.4.3 or does it matter what PHP version you use?

What WordPress and mysql versions are you selecting?

hi Nick!
I have to use php 7.4.3 on the site
Wordpress version 6.2.2
mysql 5.7.28

my computer php version is php 8.2.6. does my computer php have to be the same version as the local website? sorry if this is an obvious question I’m newbie.

I did manage to install the MySQL extension but am now getting a

“Error establishing a database connection error” when I try to run

npx local package

the command is supposed to take my local wordpress site and package it into a snapshot I can deploy to via cli

Also noticed on the website’s info.php browser output that the Configuration File Path & extension_dir are pointing to directories on my computer that don’t exist?

So I guess my questions are do I need to switch my computer’s php 8 to match the website’s php 7?

And second question would be how do I change the Configuration File Path and extension_dir for the local website - and what path should they be pointing to?

also when I run

mysql initialize

I’m getting

ERROR 1045 (28000): Access denied for user 'cc'@'localhost' (using password: NO)

thanks for your help!

Hey @dolldothouse – Welcome to the Local Community Forums!

From the terminal screenshot, it looks like the shell may not have been opened from the “Open site shell” button in Local. I say that because I see one of the first commands is a cd command to the site folder.

You’ll want to make sure that when opening a shell for a Local site, be sure to do it by clicking the “Open site shell” in Local.

The reason for this is that clicking that button adds various environment variables that are specific to the php/mysql processes. Here’s a screenshot of my machine to help visualize what I mean:

Hey Ben!

bad news is I have the localwp bug where when I click open site shell it opens then immediately closes. found that the site shell stays open under php 7.3 but my process specifically requires 7.4. development purgatory of sorts so my workaround for that was cd into the localwp site’s public folder.

good news is I got it working anyway

quick overview is

  1. manually enter site shell
  2. add the mysql extension by editing the website’s php.ini file
  3. change the default sockets in php.ini file to the Socket path listed in localwp Database settings
  4. deal with any keyring migration errors by installing chaotic keyring.
  5. deal with any character set errors involving utf8 by editing the Index.xml file to say utf8mb3

SOLVED: Workaround for “Open Site Shell” closing immediately in PHP 7.4.30:

  1. try changing your localwp php version to 7.3.5 and then Open Site Shell again. should work.
  2. if you have to use php 7.4.30 like I did just open your regular terminal and drop into the website’s public directory and use it like you would use the Open Site Shell terminal.
cd /home/username/Local Sites/sitename/app/public
  1. bonus tip: in Garuda Linux if Open Site Shell doesn’t work at all you need to install gnome-terminal
sudo pacman -S gnome-terminal

SOLVED: Error 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"

  1. find your extension_dir
php-config --extension-dir
  1. copy the output to use as the extension_dir in your website’s php.ini (my php.ini was at /home/username/Local Sites/sitename/conf/php-7.4.30/php.ini)

  2. open Visual Studio Code to edit php.ini file and add:

extension_dir= "/paste/the/extension/dir/path/here"
  1. save php.ini file

SOLVED: ERROR 2002 (HY000): Can’t connect to local server through socket ‘/run/mysqld/mysqld.sock’

  1. In localwp go to Database settings and copy the Socket path
  2. Paste into the php.ini file for default socket values
mysql.default_socket = "/the/socket/path/copied/from/localwp"
mysqli.default_socket = "/the/socket/path/copied/from/localwp" 
pdo_mysql.default_socket = "/the/socket/path/copied/from/localwp"
  1. save php.ini file

SOLVED: keyring migration error

sudo pacman -Sy chaotic-keyring

SOLVED: Character set ‘utf8’ is not a compiled character set and is not specified in the ‘/usr/share/mysql/charsets/Index.xml’ file

  1. open the Index.xml file specified in the error message.
  2. edit charset name=“utf8” to charset name=“utf8mb3”
  3. save file
  4. restart your localwp site for good measure.

Below is the successful export of my localwp site to wpcs using npx command found in the npm package

hope this helps someone with my obscure version of Linux!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.