<p>So probably the best thing you can be doing is doing your updates locally, testing them, and then pushing them to the production environment.</p>
<p>You can read more about it in the <a href="https://nystudio107.com/blog/updating-craft-cms-without-headaches" rel="nofollow noreferrer">Updating Craft CMS without Headaches</a> article.</p>
<p>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.</p>
<p>Then do the update locally, and deploy the update to your production server.</p>

CC BY-SA 4.0
2021-02-10T13:22:47.830Z
2021-02-10T13:22:47.830Z
andrew.welch
<h2>TLDR:</h2>
<p>How did you install your PHP packages? You get that error if the mysql driver wasn't installed.</p>
<h2>Longer answer:</h2>
<p>It looks like you're on Debian (and generally applies to Ubuntu as well) so if you're using <a href="https://github.com/oerdnj/deb.sury.org" rel="nofollow noreferrer">Sury's</a> popular co-installable versions, you'd need to install the <code>mysql</code> driver as well, as every PHP dependency doesn't automatically get installed by default when you do <code>apt install php7.4</code> for example.</p>
<p>The PDO driver is rolled into the <code>php-common</code> package when you install it but you still need the <code>mysql</code> driver. Craft's error message is a little misleading.</p>
<p>Do this:
<code>sudo apt install php7.4-mysql</code> then reboot FPM or apache depending on what you're running:</p>
<ul>
<li>Apache (without fpm): <code>sudo service apache2 restart</code></li>
<li>nginx / fpm: <code>sudo service php7.4-fpm restart</code></li>
</ul>
<p>The neat thing about the co-installable packages is you just need to repeat the steps above for PHP 8, just replace <code>7.4</code> with <code>8.0</code>.</p>
<h2>CLI</h2>
<p>One last gotcha, when you use Craft's CLI (eg <code>craft update all</code>), 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.</p>
<p>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.</p>
<p>To see which version is default, run the interactive <code>update-alternatives --config php</code>.</p>
<p>It will show you which version is active with an asterisk (*) and allow you to choose which one to use on the command line.</p>
<pre><code>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 &lt;enter&gt; to keep the current choice[*], or type selection number: 

</code></pre>

CC BY-SA 4.0
2021-02-10T19:55:17.867Z
2021-02-10T20:19:08.380Z
2021-02-10T20:19:08.380Z
RitterKnight
<p>After seeing that CraftCMS now supports PHP 8, I went ahead and upgraded my server to PHP 8 (formerly, PHP 7.1 was running).</p>
<p>The problem I am now facing is the following:</p>
<ol>
<li>PHP 7.1 was too low to upgrade Craft from 3.5 to 3.6.</li>
<li>Craft 3.5 does not support PHP 8, so I cannot use PHP 8 to upgrade to 3.6 either.</li>
<li>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.</li>
<li>Unfortunately, I get the following error whenever I try to run <code>php7.4 craft upgrade all</code>:</li>
</ol>
<pre class="lang-bash prettyprint-override"><code>root@debian-4gb-nbg1-1:/files# php7.4 craft update all
Fetching available updates ... done
Performing 2 updates:

    - craft 3.5.18 =&gt; 3.6.4.1
    - campaign 1.18.1 =&gt; 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 &quot;'/files/craft' 'migrate/all' '--no-backup' '--no-content'&quot; failed.

Exit Code: 1(General error)

Working directory: /files

Output:
================

    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 &quot;curl&quot; 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
</code></pre>
<p>However, <code>pdo_mysql</code> is definitely installed.</p>
<p>Is anyone able to help me?</p>

<upgrades>
Upgrading to 3.6 Impossible With PHP 8 Installed
# Upgrading to 3.6 Impossible With PHP 8 Installed

(Asked by: username_0 on 2021-02-10)

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:

PHP 7.1 was too low to upgrade Craft from 3.5 to 3.6.
Craft 3.5 does not support PHP 8, so I cannot use PHP 8 to upgrade to 3.6 either.
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.
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 => 3.6.4.1
    - 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

Output:
================

    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?

**Tags:** upgrades


---

## 2 answers

### Answer by username_1 on 2021-02-10. Score: 2

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](https://nystudio107.com/blog/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.


---

### Answer by username_2 on 2021-02-10. Score: 1

TLDR:
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.
CLI
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  to keep the current choice[*], or type selection number:


---

