Question

Cannot upgrade mysql from 5.7 to 8 (Ubunto 18)

I am trying to upgrade my mysql-server from 5.7 to 8.

I have tried many guides, and and follow the instruction, but at end I get the message :

mysql-server is already the newest version (5.7.42-0ubuntu0.18.04.1).

I did before it

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

Nothing help.

How can I solve it please. Thanks


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
July 19, 2023

Hey @yimprogramming,

MySQL 8 is not supported by default on Ubuntu 18.04, meaning it’s not available in the official Ubuntu package repositories.

However, you can install MySQL 8 on Ubuntu 18.04 by adding Oracle’s MySQL repository or by manually downloading and installing the appropriate DEB package from the MySQL official website.

Additionally, having Ubuntu 18.04 is a major security risk as the system has been EOL for quite some time.

First and most important would be to upgrade your Ubuntu server. As you are using Ubuntu 18.04, which is heavily outdated you are using outdated OS, packages, and other tools which can cause worse performance for your application/website, not to mention vulnerability issues.

Upgrade Ubuntu or go for a new Droplet

There are two ways to go about this, either upgrade your Droplet from 18.04 to 22.04 OR create a new 22.04 Droplet and migrate your WordPress over to it.

Upgrade Ubuntu

To upgrade Ubuntu you’ll basically need to run 3 commands.

  1. sudo apt update
  2. sudo apt upgrade
  3. sudo apt dist-upgrade

If you want to be a bit more though you can do something like:

sudo apt update 
sudo apt upgrade 
sudo apt full-upgrade 
sudo apt dist-upgrade 
sudo apt-get check 
sudo apt -f install 
sudo apt -y clean 
sudo apt -y autoclean 
sudo apt autoremove 
sudo dpkg --configure -a 
sudo apt --fix-broken install

but usually, the first 3 commands would do the trick.

Now, before you begin, I’ll recommend to create a Snapshot of your Droplet just to be sure you have everything backed in case of an emergency.

You can see the docs here:

https://docs.digitalocean.com/products/images/snapshots/

Snapshots are on-demand disk images of DigitalOcean Droplets and volumes saved to your account. Use them to create new Droplets and volumes with the same contents.

** IF you want to continue with the upgrade without upgrading your Droplet, something I do not recommend, you can check the bellow**

Upgrade only MySQL

Before starting, remember to backup your databases:

mysqldump --all-databases --single-transaction --easy-to-read --user=root --password > backup.sql

You may need to enter your MySQL root password to complete the dump.

Here’s a general guide on how you could upgrade from MySQL 5.7 to MySQL 8.0 on Ubuntu 18.04. Always consult up-to-date resources for the most accurate information.

  1. First, you need to add Oracle’s MySQL repository to get the newer version:
wget https://dev.mysql.com/get/mysql-apt-config_0.8.17-1_all.deb
  1. Install the MySQL APT repository:
sudo dpkg -i mysql-apt-config_0.8.17-1_all.deb

During the installation, a prompt will ask you which MySQL product you want to configure. Choose “MySQL Server & Cluster”, then select the version “mysql-8.0”. If you don’t see “mysql-8.0” in the options, choose “ok” and then choose “Apply” on the next screen. If the MySQL version is correct, select “ok” then “Apply”.

  1. Update your system’s package index:
sudo apt-get update
  1. Now you’re ready to upgrade MySQL:
apt-get upgrade mysql-server

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel