How to Install the PHP PDO MySQL Extension on Ubuntu 22.04?

10-Jan-2024

.

Admin

How to Install the PHP PDO MySQL Extension on Ubuntu 22.04?

Hello Dev,

Today, I will let you know an example of how to install the PHP pdo mysql extension on Ubuntu 22.04. In this article, we will implement a how-to install missing mysql pdo. In this article, we will implement how to install linux. We will look at an example of Apache.

To enable the PHP PDO MySQL extension on your Ubuntu server, utilize the php-mysql library. Below are the commands for installing the PHP PDO MySQL extension across different Ubuntu versions, including 22.10, 22.04, 21.10, 21.04, 20.04, 18.04, and 16.04 servers. Follow these steps to ensure seamless integration of the PDO MySQL extension into your PHP environment on Ubuntu.

Install PHP MySQL Extension in Ubuntu 22.04


Execute the following command.

sudo apt-get install php-mysql

Install PDO MySQL Extension For PHP 8.3

Execute the following command.

sudo apt-get install php8.3-mysql

Install PDO MySQL Extension For PHP 8.2

Execute the following command.

sudo apt-get install php8.2-mysql

Install PDO MySQL Extension For PHP 8.1

Execute the following command.

sudo apt-get install php8.1-mysql

Install PDO MySQL Extension For PHP 8.0

Execute the following command.

sudo apt-get install php8.0-mysql

Install PDO MySQL Extension For PHP 7.4

Execute the following command.

sudo apt-get install php7.4-mysql

Install PDO MySQL Extension For PHP 7.3

Execute the following command.

sudo apt-get install php7.3-mysql

Install PDO MySQL Extension For PHP 7.2

Execute the following command.

sudo apt-get install php7.2-mysql

Restart Apache Server

Use the following command to restart the Apache2 server.

sudo service apache2 restart

Check PHP MySQL Extension Installed

Here, execute the following command to verify whether the extension is installed or not.

php -m | grep -i mysql

Confirm the activation of the MySQL extension by creating a PHP file containing the following content and accessing it through your web browser.

<?php

phpinfo();

?>

Inspect the section that references mysql. If it is identified, the extension is effectively installed and activated.

It's essential to acknowledge that the package name (php-mysql) and web server commands may exhibit slight variations depending on your PHP version and web server. In the event of any alterations in Ubuntu 22.04, it is advisable to consult the official documentation or community resources for the latest and accurate information.

I hope it can help you...

#Ubuntu