# How to upgrade to Mautic 3.1?

**URL:** <https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203>\
**Category:** Mautic 3 - Install/Upgrade Support\
**Created:** [September 20, 2020, 12:00pm UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203 "2020-09-20T12:00:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [September 20, 2020, 12:00pm UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203/1 "2020-09-20T12:00:45Z")

</div>

The ‘Upgrade to 3.1’ button is no longer showing up in my notifications. I can’t find a page with general upgrade instructions anywhere, only [a long blog post](https://forum.mautic.org/t/mautic-3-1-new-beginnings/15787) about features and who did what, but zero word on how to install the thing. The ‘Mautic 3.1’ link in the first line leads to a 404 page.

When I go to the [original blog post here](https://www.mautic.org/blog/community/mautic-3-1-new-beginnings), the ‘Mautic 3.1’ link does work. The [github page](https://github.com/mautic/mautic/releases/tag/3.1.0) gives a lot of info about Features, Enhancements, Bugs. Again nothing about how to install it, only links to two files: [3.1.0-update.zip](https://github.com/mautic/mautic/releases/download/3.1.0/3.1.0-update.zip) and [3.1.0.zip](https://github.com/mautic/mautic/releases/download/3.1.0/3.1.0.zip). What’s the difference? Where should I put these? What was the install/upgrade command again? Run as root or user?

I can probably figure it out based on my previous experiences installing Mautic, with trial and error, but why does this have to always be so nerve-wrecking?

BTW, I am on Mautic 3, latest PHP + MySQL, Apache on CentOS, etc.

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [September 20, 2020, 6:44pm UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203/2 "2020-09-20T18:44:23Z")

</div>

Hi there

The best way to update is at the command line.

Take a look at this page which explains how to do a manual update: [https://docs.mautic.org/en/troubleshooting/update-failed](https://docs.mautic.org/en/troubleshooting/update-failed)

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [September 21, 2020, 11:34am UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203/3 "2020-09-21T11:34:38Z")

</div>

Thanks @silavapi

I will try this again next weekend. I just tried the upgrade button in admin, that suddenly reappeared, but got the following result:

The Mautic update could not complete successfully because of the following error: The ZIP archive could not be found.

Downloading Package Success  
Extracting Package Failed

😢

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [September 21, 2020, 11:46am UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203/4 "2020-09-21T11:46:36Z")

</div>

Have you got the Zip package enabled in your PHP configuration?

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [September 21, 2020, 11:49am UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203/5 "2020-09-21T11:49:45Z")

</div>

@silavapi, yes. I don’t see a zip file in the mautic folder; where is it supposed to end up?

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [September 21, 2020, 11:54am UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203/6 "2020-09-21T11:54:18Z")

</div>

Hi there, what happens if you try to do the update at the command line?

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [October 3, 2020, 1:59pm UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203/7 "2020-10-03T13:59:07Z")

</div>

Before trying some kind of manual/command line upgrade, I tried the upgrade button in the admin area notification again, now for version 3.1.1. Same result as before:

Update Available  
Current Version 3.0.2  
Upgrade Version 3.1.1  
Announcement [Release Mautic 3.1.1 · mautic/mautic · GitHub](https://github.com/mautic/mautic/releases/tag/3.1.1)  
It is HIGHLY RECOMMENDED that files and database are backed up prior to applying the update.

Updating Mautic  
The Mautic update could not complete successfully because of the following error: The ZIP archive could not be found.  
Step Status  
Downloading Package Success  
Extracting Package Failed

Where are manual/command line upgrade instructions?

The instructions on ‘[update-failed](https://docs.mautic.org/en/troubleshooting/update-failed?_ga=2.5131699.1280522791.1601732729-1724951219.1590073054)’ want me to essentially reinstall the whole thing.

> [@silavapi](#):
>
> Take a look at this page which explains how to do a manual update

It really doesn’t. It explains how to troubleshoot a failed upgrade and then gives emergency instructions to reinstall everything manually. There is nothing in there about just downloading and applying the upgrade package, which is apparently ‘the best way to update’.

Manual upgrade attempt #1:

I have downloaded an upgrade package into the mautic folder as a user (not root) with the following command:

wget [https://github.com/mautic/mautic/releases/download/3.1.1/3.1.1-update.zip](https://github.com/mautic/mautic/releases/download/3.1.1/3.1.1-update.zip)

It shows up in the folder as ‘3.1.1-update.zip’. Based on notes from previous install and upgrade attempts, the next step is probably something like this:

php bin/console mautic:update:apply --update-package=3.1.1-update.zip

That works, but produces the following error in SSH:

The stream or file “/serverpath/public\_html/mautic/var/logs/prod-2020-10  
-03.php” could not be opened: failed to open stream: Permission denied

Permission issue? Did I use root SSH where I should have used user SSH? Or the other way around?

Anyway, my Mautic installation is completely fucked again:

### The site is currently offline due to encountering an error. If the problem persists, please contact the system administrator.

#### System administrators, check server logs for errors.

Edit:

Eventually fixed after resetting ownership for all folders to the Apache user and randomly running commands from the ‘update-failed’ page as user in SSH (not root). Several errors in ‘Updating database schema…’:

In AbstractMySQLDriver.php line 106:

An exception occurred while executing ‘ALTER TABLE mtc\_oauth2\_accesstokens CHANGE cl  
ient\_id client\_id INT UNSIGNED NOT NULL, CHANGE user\_id user\_id INT UNSIGNED NOT NUL  
L, CHANGE token token VARCHAR(191) NOT NULL, CHANGE expires\_at expires\_at BIGINT DEF  
AULT NULL, CHANGE scope scope VARCHAR(191) DEFAULT NULL’:

SQLSTATE[HY000]: General error: 1832 Cannot change column ‘client\_id’: used in a for  
eign key constraint ‘FK\_818C32519EB6921’

In PDOConnection.php line 80:

SQLSTATE[HY000]: General error: 1832 Cannot change column ‘client\_id’: used in a for  
eign key constraint ‘FK\_818C32519EB6921’

In PDOConnection.php line 75:

SQLSTATE[HY000]: General error: 1832 Cannot change column ‘client\_id’: used in a for  
eign key constraint ‘FK\_818C32519EB6921’

But Mautic works again, seems to be on version 3.1.1 now and all my data is still there, hopefully.

---

<div class="post-metadata">

**Author:** ![aerendir](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/aerendir/32/1050_2.png) [@aerendir](https://forum.mautic.org/u/aerendir)\
**Post date:** [February 18, 2022, 3:53pm UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203/8 "2022-02-18T15:53:07Z")

</div>

Did you solved this? I’m facing the same issue…

---

<div class="post-metadata">

**Author:** ![aerendir](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/aerendir/32/1050_2.png) [@aerendir](https://forum.mautic.org/u/aerendir)\
**Post date:** [February 18, 2022, 4:01pm UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203/9 "2022-02-18T16:01:31Z")

</div>

This is an old issue and there is already an open 3d for it:

> [@Error Updating from Mautic 3.0 --\>3.01](https://forum.mautic.org/t/error-updating-from-mautic-3-0-3-01/15038/11):
>
> Dropping the foreign key doesn’t work. Once dropped, running a bin/console doctrine:schema:update --force tries to recreate the foreign key, but the query results in an error: An exception occurred while executing ‘ALTER TABLE \*\_oauth2\_accesstokens ADD CONSTRAINT FK\_E6019FAD19EB6921 FOREIGN KEY (client\_id) REFERENCES \*\_oauth2\_clients (id) ON DELETE CASCADE’: SQLSTATE[HY000]: General error: 3780 Referencing column ‘client\_id’ and referenced column ‘id’ in foreign key constraint ‘FK\_E6019FAD19…

---

<div class="post-metadata">

**Author:** ![aficio](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/aficio/32/12659_2.png) [@aficio](https://forum.mautic.org/u/aficio)\
**Post date:** [July 8, 2024, 1:58am UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203/10 "2024-07-08T01:58:25Z")

</div>

I [developed a tool](https://github.com/aficiomaquinas/mautic-fix-db-ai) using artificial intelligence to address these issues. Ultimately, I successfully resolved the problem, although it required running numerous SQL queries.

---

<div class="post-metadata">

**Author:** ![tobsowo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/tobsowo/32/3096_2.png) [@tobsowo](https://forum.mautic.org/u/tobsowo)\
**Post date:** [July 8, 2024, 9:09pm UTC](https://forum.mautic.org/t/how-to-upgrade-to-mautic-3-1/16203/11 "2024-07-08T21:09:17Z")

</div>

This looks cool.
