We will Upgrade MySQL Server from 5.7 to 8 in Ubuntu 18.04 by using the command line in a few steps.
The Upgrade of the MySQL server is for the performance and security improvements.
So before upgrading the MySQL servers from 5.7 to 8 take the backup of databases and the configuration files.
To take the backup use the “mysqldump” command and backup all the databases with the Master user of the databases.
$ mysqldump --lock-all-tables --all-databases -uroot -proot > all_databases.sql
So, after taking the backup of the mysql databases take the backup of the configuration file using “cp command” in the terminal.
$ sudo cp /etc/my.cnf /etc/my.cnf_bkp
Also, you can check the version of the database by login into the MySQL database.
$ mysql -uroot -proot
So After login to the server, we can see the MySQL version there are many other options to look at the versions of MySQL.
Now let’s see step by step to Upgrade MySQL Server from 5.7 to 8 Ubuntu 18.04. Find the cheat sheet and after Upgrade please come and read the whole post.
Cheat Sheet to Upgrade MySQL server from 5.7 to 8 in Ubuntu.
STEP 1: Stop the MySQL server 5.7
So, before upgrading, we will stop the MySQL server 5.7 in Ubuntu by using the “systemctl command”.
$ sudo systemctl stop mysql
STEP 2: Download the Repository and Install the Package of MySQL 8.0 to Upgrade.
So when the server gets stopped we will download the repository by using the “wget command”.
$ wget https://repo.mysql.com/mysql-apt-config_0.8.14-1_all.deb
We have downloaded the package, if you want to download the package of any other version can visit the official website of MySQL.
Now let’s install the package by using “dpkg command” in the command line terminal.
$ sudo dpkg -i mysql-apt-config_0.8.14-1_all.deb
So we will get some prompts while installing the .deb package into the Ubuntu Server.
Select the Product “MySQL Server & Cluster” and press “Enter”.
Now select the version “mysql-8.0” and press “Enter” move to next part and “press OK”
So we have added the repository successfully into the Ubuntu Server.
STEP 3: Upgrade MySQL Server from 5.7 to 8 Ubuntu 18.04.
So after adding repo we will update the repo by using the “apt update command”.
$ sudo apt-get update
Now we will upgrade the MySQL Server from 5.7 to 8 using “apt install mysql-server”
$ sudo apt-get install mysql-server
So while installing the MySQL server it will prompt for the default authentication plugin.
Select “Use Strong Password Encryption” and click on “OK”.
STEP 4: Check the Version of MySQL Server which is running after Upgrade.
So to check the version firstly we will check the status by using “systemctl”
$ sudo systemctl status mysql
Now login to the server to check the version of MySQL version
$ mysql -uroot -proot
So here we have successfully upgraded the MySQL server version from 5.7 to 8.