How to Upgrade Moodle 4.2.5 to Moodle 5.0.1

To upgrade Moodle 4.2.5 to Moodle 5.0.1, follow this structured process, which aligns with Moodle’s official documentation and best practices1234:

1. Check Server & Software Requirements

  • Supported Upgrade Path: You can upgrade directly from 4.2.5 to 5.0.1 (Moodle 5.0 only supports upgrades from 4.2.3 or later)12.
  • PHP: Minimum 8.2.0 (64-bit only). PHP 8.3.x/8.4.x also supported.
  • Database: PostgreSQL 14+, MySQL 8.4+, MariaDB 10.11.0+, SQL Server 2017+. Oracle is not supported in Moodle 5.0+.
  • PHP Extensions: sodium is required.
  • PHP Setting: max_input_vars must be ≥ 5000.
  • Database Prefix: Must not exceed 10 characters.
  • In Moodle, go to Site administration > Server > Environment and check for any warnings or errors for Moodle 5.013.

2. Preparation & Backup

  • Test the upgrade on a copy of your production site first13.
  • Backup these three areas:
    • Moodle software files (your Moodle directory)
    • Moodle data directory (usually moodledata)
    • Moodle database (full SQL dump)134

3. Check Plugins

  • Visit Site administration > Plugins > Plugins overview.
  • Update all plugins and themes to versions compatible with Moodle 5.01.
  • If a plugin is not compatible, remove its code (do not uninstall via the UI, to preserve data), or update it1.

4. Enable Maintenance Mode

  • Go to Site administration > Server > Maintenance mode and enable it14.

5. Replace Moodle Code

  1. Download Moodle 5.0.1 from the [official Moodle download page]4.
  2. Upload the new Moodle package to your server.
  3. Create a backup of your current Moodle code (e.g., move everything in your Moodle directory to a new folder like OLDSITE)4.
  4. Extract the new Moodle code into your Moodle directory4.
  5. Copy config.php from OLDSITE to the new Moodle directory4.
  6. Copy any custom plugins/themes (ensure they are compatible).
  7. Do not overwrite the moodledata directory.

6. Start the Upgrade Process

  • Web Interface: Open your Moodle site in a browser. The upgrade will start automatically—follow on-screen instructions134.
  • Command Line (recommended for large sites): bashphp admin/cli/upgrade.php
  • The process will check plugins and update the database schema15.

7. Post-Upgrade Steps

  • Complete the upgrade: Ensure all steps show “success” and resolve any plugin issues15.
  • Disable maintenance mode.
  • Test your site: Check user logins, course access, file uploads, and plugin functionality.
  • Review logs for errors.

8. Cleanup

  • Once satisfied, you may delete the backup of your old Moodle code (OLDSITE). Keep your database and data directory backups for a while4.

Upgrade Steps Summary Table

StepAction
Check RequirementsPHP, DB, extensions, environment check
BackupMoodle code, moodledata, database
Plugin CompatibilityUpdate or remove incompatible plugins
Maintenance ModeEnable via admin interface
Replace CodeUpload/extract Moodle 5.0.1, restore config.php, custom plugins
Start UpgradeVisit site or run CLI upgrade script
Post-Upgrade ChecksTest site, resolve issues, disable maintenance mode
CleanupRemove old code backup after confirming stability

Important Notes

  • Never skip backups.
  • Test the upgrade on a staging copy first.
  • Check plugin compatibility before upgrading.
  • Do not use Oracle Database—unsupported in Moodle 5.0+.
  • Upgrade may take significant time for large sites—plan accordingly.

For full details, consult the [Moodle Upgrading documentation]13.

References:
1: Moodle Upgrading Guide
2: Moodle 5.0 Release Notes
3: Upgrade Overview
4: Tech Fry: How to Upgrade Moodle

  1. https://docs.moodle.org/en/Upgrading
  2. https://moodledev.io/general/releases/5.0
  3. https://docs.moodle.org/en/Upgrade_overview
  4. https://www.techfry.com/moodle/how-to-upgrade-moodle
  5. https://www.youtube.com/watch?v=eGzlGvCyXVA
  6. https://docs.moodle.org/en/Upgrading_FAQ
  7. https://www.idslogic.com/blog/moodle-5-0-release-features-enhancements-lms-upgrade
  8. https://mindfieldconsulting.com/how-to-upgrade-moodle-from-2-0-and-2-x-to-latest-version/
  9. https://www.youtube.com/watch?v=0ejRODDEHJg
  10. https://www.youtube.com/watch?v=aSoW-Jd3xqs