How to fix Ubuntu PHP error: Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

Problem:

When loading your wordpress page, you see the following message:

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

Solution

Install the php[VERSION]-mysql package for the PHP version that is running wordpress.

For example:

sudo apt -y install php8.1-mysql