I had MySQL 5.5.60 installation on an AWS EC2 instance (Linux 2018.03) and had to upgrade it to 5.7 as the official end of life for 5.5 has long expired. Additionally, WordPress started to suggest using version 5.6 later.
Before going to upgrade existing MySQL installation, -ssh
your instance and check the version of your existing service with the following command:
mysqld --version
Note: You should be able to run commands as the root user in order to complete the upgrade. Running
sudo su
logs you in as the root user. You may be asked a password for the user.
As a person knowing very little about Linux, MySQL, and other systems/services alike, my main concern was if I was going to lose the existing MySQL data after the upgrade. The fact is I did not lose any data after the upgrade. But I took some actions beforehand in case I mess up: took a snapshot of the EC2 volume attached to the running instance and copied MySQL data to a temporary folder using -ssh access. If your MySQL data is in /var/lib/mysql
and if you want to copy the data to /tmp/mysql.bck
, you can use this command in your Linux server:
cp -R /var/lib/mysql /tmp/mysql.bck
This will create mysql.bck
folder within the tmp
folder and will copy existing MySQL files to the mysql.bck
folder.
Upgrading to 5.6
You should first remove the existing MySQL service installation. Assuming your MySQL version is 5.5 and you ssh
as the root user, you should run this command to remove the existing installation:
sudo yum remove mysql55-server
Now you need to install the version 5.6. The following command will do it for you:
sudo yum install mysql56-server
After running this command, you may encounter an error stating a conflict with another existing service. This was an error I got:
Error: perl-DBD-MySQL56 conflicts with perl-DBD-MySQL55-4.023-5.23.amzn1.x86_64
This can be solved by just removing conflicting installations. The new installation will upgrade the removed service too as you can see from the error message. This command will remove the conflicting service:
sudo yum remove perl-DBD-MySQL55
After removing the conflicting installation, run the command for the 5.6 installation again. This should complete the installation. Go ahead and check the version. You may need to start the MySQL service after installation. This code will do that:
sudo service mysqld start
Upgrading to 5.7
The same steps can be taken to upgrade to version 5.7: mysql-56
should be removed and mysql-57
should be installed. In other words, run the following commands one-by-one:
sudo yum remove mysql56-server
sudo yum install mysql57-server
sudo service mysqld start
This is it. End of life MySQL 5.7 is expected to be October 21, 2023, and it means we have some time to dig into upgrading to version 8. Hope you enjoy this post.