Blog

Migration from MySQL 5.7 to MySQL 8.0: everything you need to know

Since October 2023, MySQL 5.7 is no longer supported. If you run a website or manage databases, moving to MySQL 8.0 becomes essential to maintain their security and performance.

Discover our step-by-step guide to successfully complete your migration!

Why migrate from MySQL 5.7 to MySQL 8.0?

With the end of support for MySQL 5.7, your databases are now exposed to potential security risks. Without regular updates, unpatched vulnerabilities can put your sensitive information at risk.

However, migrating from MySQL 5.7 to MySQL 8.0 is not only about security. Indeed, this new version includes significant improvements:

  • Improved performance : Thanks to optimized processing algorithms, MySQL 8.0 processes data faster, which significantly reduces load times and increases the operational efficiency of your sites and applications.
  • Enhanced security : This new version includes sophisticated encryption options and improved user management, forming a robust barrier against intrusions and unauthorized access.
  • Query optimization : MySQL 8.0 simplifies the handling of complex queries with advanced optimization. Result: reduced response times, a better user experience, and more intuitive use of resources.

Preparing for the migration from MySQL 5.7 to MySQL 8.0

Thorough preparation reduces the risk of service interruptions and post-migration errors. Here are the preliminary steps to ensure a smooth transition:

Assess the current environment

Take inventory of your databases and associated applications to identify all dependencies. Use tools like MySQL Workbench to extract precise schemas or opt for Excel spreadsheets for detailed tracking.

This process helps understand which data is handled and by which applications, making migration planning easier.

Back up your data

Before starting the migration, create full copies of your databases. Use robust backup solutions like MySQL Enterprise Backup for optimal safety or cloud services such as Amazon S3 for secure external storage.

This task is generally the responsibility of the company's IT manager or database administrator.

Update your extensions and applications

Ensure your extensions, themes, and applications are compatible with MySQL 8.0. To do so, check plugin change logs or test them in a MySQL 8.0 development environment.

You can also take advantage of this migration to review the code and remove obsolete elements.

This step often involves collaboration between developers and database administrators to ensure a smooth transition and avoid incompatibilities.

If you don't have a dedicated IT department in your company, you can call on a network administrator on Codeur.com, to help you plan and secure your migration from MySQL 5.7 to MySQL 8.0.

Steps to migrate from MySQL 5.7 to MySQL 8.0

Starting a migration to MySQL 8.0 is a delicate process, hence the importance of carrying it out step by step.

Upgrade server infrastructure (if needed)

First, check whether your current server can handle MySQL 8.0. This version generally requires more resources than MySQL 5.7, notably in terms of memory (at least 2 GB recommended) and processing power.

A tip: consult the official MySQL documentation to obtain detailed specifications and compare these requirements with your current configuration. If necessary, consider a hardware upgrade or migrating to a virtual or dedicated server to better meet these needs.

Install MySQL 8.0

For installing MySQL 8.0, instead of MySQL 5.7, you have two approaches:

1) A parallel installation

This method allows MySQL 8.0 to coexist with MySQL 5.7 on the same system. You install the recent version without disabling the old one, which lets you test new features and ensure compatibility of your applications, plugins, and templates with peace of mind.

The main advantage is minimizing the risk of disrupting your production environment, since you can identify and resolve compatibility issues gradually.

2) On-site update

This method consists of directly updating your current MySQL 5.7 installation to MySQL 8.0. It is generally faster and consumes fewer resources because it does not require maintaining two parallel systems.

However, the risk is higher: any error or incompatibility during the process immediately affects your production data. It is therefore mandatory to make complete backups before proceeding.

Choosing between these methods depends on your ability to manage risk and your available system resources.

Migrating data from MySQL 5.7 to MySQL 8.0

To actually migrate data from MySQL 5.7 to MySQL 8.0, follow these steps:

  1. Data export : Use the command mysqldump to create a backup copy of your database. Run:
mysqldump -u votre_utilisateur -p votre_base_de_donnees > backup.sql

This will generate an SQL file containing all the data.

  • Import into MySQL 8.0 : After installing MySQL 8.0, import the backup file using:
mysql -u votre_utilisateur -p votre_base_de_donnees < backup.sql
  • Verification : Compare the records in your new database to confirm that all data has been transferred correctly.

Functional and performance testing

The final step is to ensure that everything works as expected. Perform functional tests to see if your applications interact correctly with MySQL 8.0:

  1. After the migration, run mysql_upgrade to update your tables and indexes to the new MySQL 8.0 standards. Type:
mysql_upgrade -u root -p

This allows you to check and repair tables to ensure compatibility.

  1. Test the key features of your applications to ensure they interact correctly with the new MySQL version. Check transactions, queries, and performance to detect any issues.

Anticipate your host's automatic migration to MySQL 8.0

In the coming weeks, many hosts plan to automatically perform the transition from MySQL 5.7 to MySQL 8.0 for their customers. Although this automatic migration is convenient, it requires your attention, especially if you use content management systems like PrestaShop, WordPress, Craft CMS, Magento…

These CMS are generally prepared to adapt to MySQL 8.0, but themes and plugins might not be.

Your host will send you an email to notify you of the migration date. At that time, make a full backup of your site. This will allow you to restore the previous version if any problems occur.

Also check the compatibility of your plugins and themes to anticipate possible application changes or updates.

Finally, as soon as the update to MySQL 8.0 is complete (you will be notified again!), immediately review your site for any errors or data loss. Focus on core functionalities, paying special attention to areas affected by plugins or themes.

Our advice for a successful migration from MySQL 5.7 to MySQL 8.0

Migrating to MySQL 8.0 brings long-term benefits in performance and security. For a worry-free migration, the key is to plan the process now, carefully schedule each step, and back up your data.

Get in touch now with a MySQL developer on Codeur.com, for personalized and effective support!