• Ways to Fix the “PHP Missing MySQL Extension” Error in WordPress

    Despite being a stable platform, errors or missing PHP installation extensions are nothing new to WordPress. This error generally occurs in cases where the required MySQL extensions are not properly installed or enabled in your specific PHP environment. Here is a helpful guideline to fix that error. 

    First, you need to make sure the fact that your PHP and WordPress versions are compatible. Check whether you have already installed MySQL extensions and focus on modifying php.ini to rectify tentative misconfigurations. Based on the access level, you have options to troubleshoot the issue using the WordPress dashboard, accessing server files using SFTP, or with the help of a command line interface via SSH.

    Step 1-  Do Required Updates on  the Basic WordPress Software 

    • Select Dashboard and after that Updates.
    • The system will show an option if any new WordPress version is available. Click  Update Now for the newest version installation.

    Step 2- Check the Status of MySQL PHP Extension in the WordPress Health Tool

    WordPress has a pre-existing health tool that developers can use to check the PHP and MySQL extension’s status. Follow these steps there

    • Log into the WordPress Dashboard.
    • Go to Tools and then select Site Health.
    • Click the Info tab.

    To check the PHP version, expand the server section. Here’s an example of version 8.2.12.

    • If you have an older PHP version than 7.4, go after these steps
    • Contact and ask the web host for a PHP update.
    • Use the server management interface of the web host for updates.
    • SSH into the server of WordPress and update PHP from the command line.
    • Now check the database section and make sure MySQL for PHP is installed.

    Text below image– Here is an example where the extension is active and installed properly.

    Step 3- Check the Status of PHP Extension in info.php File

    Users have the option to check the MySQL PHP extension status by connecting to the  WordPress server with FTP clients or web hosting control panels.

    For extension status checking follow these steps:

    • Explore the root directory of the site and create a new file named info.php.
    • Add the code mentioned below to the info.php file:

    <?php phpinfo(); ?>

    • Save the changes and exit the file.
    • Navigate the URL to view the file in the web browser

    http://yourdomain.com/info.php

    Replace the part yourdomain.com with your website’s real domain name

    You will be able to see the latest PHP version on the top of the screen. PHP version 7.4 is enough. But if you want an improved security, use the latest version.

     Press Ctrl+F and start to search for mysqli and pdo_mysql sections in the info.php output to to make sure your MySQL extensions are enabled correctly.

    If you find the Client API library version field in the mysqli or pdo_mysql sections is empty chances are there that MySQL

    extensions for PHP are missing. Generally, users can manage the PHP extensions using the server’s control panel. Before you install or activate the MySQL extensions, get in touch with the hosting provider to get instructions for your hosting environment.  

    Step 4- Be sure to Check the PHP Extension Settings in the php.ini File

    Website updates or migrations can impact the PHP configuration settings badly. 

    The extension_dir setting impacts how WordPress locates PHP extensions. And it’s a reason  behind missing MySQL and PHP extensions

    For the setting verification in the php.ini file, follow these steps

    Open a web browser and then open an info.php file and locate the Loaded Configuration File entry. This example presents the path to the active php.ini file for XAMPP on Windows:

    This path shows the location of the PHP configuration file on your server.Now check the extension_dir entry within the Core section on the same page to verify the directory PHP uses for the loading extensions.

    In case you identify the extension_dir field wrong or empty, open the php.ini file via the host’s control panel or the command line and locate the extension_dir setting.Now it is time to update the extension_dir setting to choose the right path for the PHP extensions. Make sure this one matches the directory path noted in the info.php file and that the line is not missed.

    After you are done with the changes, save the fileexit the editor, and then restart the webserver to check the changes.

    Step 5- Know the PHP Extension Status from the Command Line

    At this step, first log in to the server hosting the WordPress site locally or using SSH.

    Do a check on the installed PHP version using the following command:

    php –v

    text below image – Here you can see the currently installed PHP version

    Check whether you have the properly installed mysqli or PDO_MySQL extensions. Check this by giving the following command.

    php -m | grep mysqli

    php -m | grep pdo_mysql

    If mysqli and pdo_mysql appear in the output, this confirms that the extensions are installed and active.

    You will be able to see command searches using PHP modules and filters for  mysqli or pdo_mysql. If you see mysqli and pdo_mysql in the output it indicates you have properly installed and active extensions.

    If you find the extensions are not installed correctly, use the following commands for the updates:

    sudo apt update

    sudo apt install php-mysqli

    sudo apt install php-pdo-mysql

    Replace php-mysqli and php-pdo-mysql in the command according to your current PHP version in your system. 

    To know the changes restart your server.

    If you’re using an Apache server, run the command 

    sudo systemctl restart apache2

    For the Nginx servers use the command:

    sudo systemctl restart nginx 

    Wrapping Up

    Hopefully, going after these tricks will help you troubleshoot issues related to Missing PHP MySQL Extension in WordPress. 

© 2024 Euphoriagenx. All Rights Reserved