52

How do I update to MySQL 8.0 from the default version (5.7)?

It's important for me for it to make an update and not re-install MySQL so all my data won't be corrupt.

There is not a lot of info regarding this issue since it was only released not long ago with tons of awesome new features!

This is what I have found that seems like it will only update and not destroy my data. I'm not going to proceed until I'm sure.

Imnotapotato
  • 5,308
  • 13
  • 80
  • 147

3 Answers3

89

You can find answer in mysql doc. It has full details about how to upgrade. Make sure to back up data before upgrading.

There are tons of ways to upgrade in the docs. The way i choose is to use APT Repository.

You should do the following things:

First, add the MySQL APT repository to your system's software repository list. The details in docs are a little abstract , i'll give a example:

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

Then you'll get this:

enter image description here

press Enter when you choose mysql server ,then select mysql 8.0.Finally choose like this:

enter image description here

Once the repo has been added, update apt index and install mysql-server:

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

Now if you don't get any error messages, you have already upgraded successfully. You can confirm by:

apt policy mysql-server

You will get output like this:

$ apt policy mysql-server
  mysql-server:
      Installed: 8.0.13-1ubuntu18.04
      Candidate: 8.0.13-1ubuntu18.04
bfontaine
  • 18,169
  • 13
  • 73
  • 107
请叫我小马哥
  • 1,653
  • 13
  • 11
  • 2
    In Ubuntu 14.04 the command should be `apt-cache policy mysql-server` instead of `apt policy mysql-server` – qatz Nov 25 '18 at 15:55
  • For WSL you may need to run: curl -sL "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x8C718D3B5072E1F5" | sudo apt-key add – ykay says Reinstate Monica Mar 17 '19 at 15:18
  • 5
    This doesn't seem to work anymore `Err:5 http://repo.mysql.com/apt/ubuntu bionic InRelease The following signatures were invalid: EXPKEYSIG 8C718D3B5072E1F5 MySQL Release Engineering ` – Eugene van der Merwe May 21 '19 at 17:58
  • 1
    I think you may get help from this :https://unix.stackexchange.com/questions/387053/debian-9-apt-and-gpg-error-inrelease-the-following-signatures-were-inva @Eugene van der Merwe – 请叫我小马哥 May 22 '19 at 03:30
  • 3
    @EugenevanderMerwe for me it worked well: sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 8C718D3B5072E1F5 – Fernando Souza Oct 22 '19 at 20:25
  • I also got the "Following signatures were invalid." error. Downloading the latest from the oracle site solved it. Ubuntu 18.04 for me. – Ross117 Nov 11 '19 at 03:25
  • 1
    This process worked for me after changing wget https://repo.mysql.com//mysql-apt-config_0.8.10-1_all.deb to wget https://repo.mysql.com//mysql-apt-config_0.8.15-1_all.deb – Ankit Sharma Mar 04 '20 at 13:01
  • I want to upgrade mysql in ubuntu docker image, but with this method I'm getting error related to GUI, how do I skip the GUI configuration? – Bhavay Anand Apr 01 '21 at 08:40
  • The newest version (November 2022) is https://repo.mysql.com/mysql-apt-config_0.8.24-1_all.deb - if you are trying this in the future, get the link to the newest version from here https://repo.mysql.com/ – Talik Nov 21 '22 at 14:23
2

Use Mysql manual https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/#apt-repo-fresh-install

The sequence there is about the same, but it seems that the link to the settings file is changing. I use https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb

F00x
  • 124
  • 6
  • 3
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Rot-man May 16 '19 at 02:57
0

I have small appendix to the helpful answer by 请叫我小马哥.

My challenge was to update MySQL client from 5.7 to 8.0. I needed that because I got warnings when tried to export remote 8.0 database with client 5.7 and MySQL Workbench 6.3 at my ubuntu 18.04 machine. I did not have MySQL server installed and I did not intend to do it.

The install command was

sudo apt-get install mysql-community-client

The next step was to install MySQL Workbench Community 8.0 because 6.3 threw mysqldump version error when tried to export. I have done the instalation in lamer's way using ubuntu Software app. This probably saved me connection issues because I could at once apply required commands as detailed in the description:

sudo snap connect mysql-workbench-community:password-manager-service 
sudo snap connect mysql-workbench-community:ssh-keys
sudo snap connect mysql-workbench-community:cups-control

The last one did not work for me, so I skipped it:

sudo snap connect mysql-workbench-community:cups-control
Kuba D
  • 93
  • 1
  • 7