Upgrading MySQL is a task that is almost inevitable if you have been managing a MySQL installation for any length of time.
There are 2 basic options available when upgrading from one MySQL instance to another:
- Perform a ‘Dump’ Upgrade
- Perform an ‘In Place’ Upgrade
We are going to do an ‘In Place’ upgrade here, which involves shutting down the existing (older) MySQL instance, upgrading the installed MySQL server package and binaries, starting up that (newer) instance using the new mysqld server binary, and then running mysql_upgrade.
Before upgrading, the MySQL server needs to be shut down properly.
It’s advised that the value of variable ‘innodb_fast_shutdown’ is set to zero which will ensure a proper shutdown.
mysql > set global innodb_fast_shutdown=0
To shut the service down, exit from MySQL and type the following command in terminal
$ sudo service mysql stop
MySQL service is in the down state at the moment. To check whether it’s fully shutdown
$ sudo service mysql status
To continue with the upgrade process, we need to get up-to-date package information on MySQL APT repository. For this
$ sudo dpkg -i mysql-apt-config_0.7.2-1_all.deb
[If the file mysql-apt-config_0.7.2-1_all.deb is missing in the server, you can download it from here]
During installation process you will be prompted to select the version you’re upgrading the MySQL server to.
Choose MySQL 5.7 version.
To download the package lists from the repositories and update them to get information on the newest versions of packages and their dependencies
$ sudo apt-get update
Now to install the latest version
$ sudo apt-get install mysql-server
During installation process you will be prompted to enter a password for MySQL root user.
For upgrade process, you don’t have to change the password. Keep the old password and continue.
After installation you can verify the installed version using the command
$ dpkg -l | grep mysql | grep ii
Finally to upgrade the database
$ sudo mysql_upgrade -uroot –p
Your MySQL server will be upgraded to 5.7 version now.