Upgrade MySQL Server from 5.7 to 8 Ubuntu 18.04.

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 usingcp commandin 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
Upgrade MySQL Server from 5.7 to 8 Ubuntu 18.04.

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.

1. Stop the MySQL server.

$ sudo systemctl stop mysql

2. Download the Repository and Install the Package.

$ wget https://repo.mysql.com/mysql-apt-config_0.8.14-1_all.deb
$ sudo dpkg -i mysql-apt-config_0.8.14-1_all.deb

3. Upgrade MySQL Server from 5.7 to 8 Ubuntu 18.04.

$ sudo apt-get update
$ sudo apt-get install mysql-server

4. Check the Version of MySQL Server which is running after Upgrade.

$ sudo systemctl status mysql
$ mysql -uroot -proot

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.

Upgrade MySQL Server from 5.7 to 8 Ubuntu 18.04.

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”

Upgrade MySQL Server from 5.7 to 8 Ubuntu 18.04.
Upgrade MySQL Server from 5.7 to 8 Ubuntu 18.04.

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.

Learn more about how to install MySQL 8 in CentOS and Ubuntu, how to upgrade MySQL 5.5 to 5.7.

3 Replies to “Upgrade MySQL Server from 5.7 to 8 Ubuntu 18.04.

  1. Hi,
    one step was missing for me BEFORE sudo apt-get update:
    Had to import the missing GPG key:

    sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 467B942D3A79BD29

    Apart from this it worked well – thanks for the how-to!

Give your valuable time