After seeing that CraftCMS now supports PHP 8, I went ahead and upgraded my server to PHP 8 (formerly, PHP 7.1 was running).

The problem I am now facing is the following:

  1. PHP 7.1 was too low to upgrade Craft from 3.5 to 3.6.
  2. Craft 3.5 does not support PHP 8, so I cannot use PHP 8 to upgrade to 3.6 either.
  3. I then installed PHP 7.4 alongside PHP 8, as it seems to be the only PHP version that is able to upgrade from 3.5 to 3.6.
  4. Unfortunately, I get the following error whenever I try to run php7.4 craft upgrade all:
root@debian-4gb-nbg1-1:/files# php7.4 craft update all
Fetching available updates ... done
Performing 2 updates:

    - craft 3.5.18 =>
    - campaign 1.18.1 => 1.18.2

Backup the database? (yes|no) [yes]:
Backing up the database ... done
Performing update with Composer ... done
Applying new migrations ... error: The command "'/files/craft' 'migrate/all' '--no-backup' '--no-content'" failed.

Exit Code: 1(General error)

Working directory: /files


    Craft can’t connect to the database. Check your connection settings.

Yii Migration Tool (based on Yii v2.0.40)

Error Output:
PHP Warning:  Module "curl" is already loaded in Unknown on line 0
Exception 'craft\errors\DbConnectException' with message 'Craft CMS requires the PDO_MYSQL driver to operate.'

in /files/vendor/craftcms/cms/src/db/Connection.php:161

Caused by: Exception 'yii\db\Exception' with message 'could not find driver'

in /files/vendor/yiisoft/yii2/db/Connection.php:642

Caused by: Exception 'PDOException' with message 'could not find driver'

in /files/vendor/yiisoft/yii2/db/Connection.php:710

However, pdo_mysql is definitely installed.

Is anyone able to help me?


So probably the best thing you can be doing is doing your updates locally, testing them, and then pushing them to the production environment.

You can read more about it in the Updating Craft CMS without Headaches article.

You still have the opportunity to do this here... get a local dev environment set up, pull down your code and database, then get it up and running on a PHP version such as PHP 7.4 that will work with older versions of Craft as well as Craft 3.6.

Then do the update locally, and deploy the update to your production server.



How did you install your PHP packages? You get that error if the mysql driver wasn't installed.

Longer answer:

It looks like you're on Debian (and generally applies to Ubuntu as well) so if you're using Sury's popular co-installable versions, you'd need to install the mysql driver as well, as every PHP dependency doesn't automatically get installed by default when you do apt install php7.4 for example.

The PDO driver is rolled into the php-common package when you install it but you still need the mysql driver. Craft's error message is a little misleading.

Do this: sudo apt install php7.4-mysql then reboot FPM or apache depending on what you're running:

  • Apache (without fpm): sudo service apache2 restart
  • nginx / fpm: sudo service php7.4-fpm restart

The neat thing about the co-installable packages is you just need to repeat the steps above for PHP 8, just replace 7.4 with 8.0.


One last gotcha, when you use Craft's CLI (eg craft update all), it uses the command line version of PHP, which may or may not be the same as the version the web server is currently using. This is especially the case with FPM versions. IIRC when you update to PHP 8, it makes that version the default.

You addressed this by using the version number directly on the prompt but another way to handle this is to set the CLI version directly.

To see which version is default, run the interactive update-alternatives --config php.

It will show you which version is active with an asterisk (*) and allow you to choose which one to use on the command line.

There are 2 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
  0            /usr/bin/php8.0   80        auto mode
* 1            /usr/bin/php7.4   74        manual mode
  2            /usr/bin/php8.0   80        manual mode

Press <enter> to keep the current choice[*], or type selection number: 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.