PHP solve mbstring extension missing

Posted on Aug 08, 2022

Learn how to fix mbstring extension is missing error in PHP configuration

Photo from Unsplash

When running phpMyAdmin, you may see an error that says the mbstring extension is missing as follows:

This error prevents you from opening phpMyAdmin and accessing your database.

To solve this error, you need to have mbstring installed and activated in your PHP configuration.

Depending on your Operating System, there are different ways to install and enable the mbstring extension:

Install mbstring for Linux

For Linux systems, you can install mbstring using apt-get or yum depending on your Linux distribution.

Here’s the command to install mbstring for Debian / Ubuntu or Red Hat Linux:

sudo apt-get install php-mbstring

# for RHL:
sudo yum install php-mbstring

The package manager should install the right mbstring version based on your PHP version.

If not, you need to specify the version as follows:

# install mbstring v8.1
sudo apt-get install php8.1-mbstring

# install mbstring v7.4
sudo apt-get install php7.4-mbstring

Once the extenson is installed, you need to restart your PHP server.

For Apache, run the following command:

service httpd restart

Now you can check if the mbstring extension is enabled by running phpinfo() function to see the mbstring enabled:

You can also run the php -m | grep mbstring command to see the extension from the command line:

$ php -m | grep mbstring
mbstring

Now that the mbstring extension is available, you should be able to access phpMyAdmin.

Install mbstring for Windows

For Windows system, you need to enable the mbstring extension from the php.ini file.

Look for the line extension=php_mbstring.dll in your php.ini file as follows:

;extension=php_mssql.dll
;extension=php_mbstring.dll
;extension=php_exif.dll  
extension=php_mysql.dll

You need to remove the semicolon before the extension config to enable php_mbstring.dll for Windows.

;extension=php_mssql.dll
extension=php_mbstring.dll
;extension=php_exif.dll  
extension=php_mysql.dll

Once you enable the extension, restart your PHP server. The mbstring extension should now be available on your Windows computer.

If that doesn’t work, search your php.ini file for the extension_dir config.

You should see where PHP look for the extensions as shown below:

extension_dir = "D:\XAMPP\php\ext"

You need to see if the php_mbstring.dll exists inside the D:\XAMPP\php\ext path. Copy the extension directory value and paste it to your explorer windows.

If the .dll file is not present, you need to download the PHP Windows build from windows.php.net as shown below:

Extract the downloaded zip file, then look for the php_mbstring.dll file from the ext/ folder. Copy the file to your extension_dir path.

I don’t recommend downloading dll files from the Internet because you may get a virus on your computer.

Restart your PHP server, and now the mbstring extension should be available.

And that’s how you enable mbstring on Windows computers.

Install mbstring for macOS

For macOS, the PHP formula from Homebrew already enabled the mbstring extension during the installation process.

You should have mbstring enabled by default when you install PHP using Homebrew.

But if you install PHP using MacPorts, then you may need to install mbstring separately.

The following command should work when you’re using MacPorts:

# 👇 install PHP 7.4 mbstring 

sudo port install php74-mbstring

# 👇 install PHP 8.0 mbstring 

sudo port install php80-mbstring

You can see the available mbstring version from macports.org.

Now you’ve learned how to enable the PHP mbstring extension on macOS. Good work! 👍

Level up your programming skills

I'm sending out an occasional email with the latest programming tutorials. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.