8

I have a Drupal site 8.6.10 on an Ubuntu server 18.04 with MySQL 5.7.25

I want to update MySQL to version 8.0

Here are the steps I followed :

  1. I backed up my database.

  2. I uninstalled MySQL from my server with the commands :

    $ sudo systemctl stop mysql
    $ sudo apt remove mysql-*
    $ sudo apt purge mysql-*
    $ sudo apt autoremove
    $ sudo dpkg -l | grep mysql | grep ii
    
  3. I added the repository with the command :

    $ wget https://repo.mysql.com//mysql-apt-config_0.8.12-1_all.deb
    
  4. I installed the package with the command :

    $ sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb
    

enter image description here

enter image description here

enter image description here

enter image description here

My problem :

  1. I install MySQL with the command :

    $ sudo apt update
    $ sudo apt install mysql-server
    

When I do step 5, it installs MySQL 5.7 why does not it install version 8 ?

enter image description here

4
  • 2
    wget https://repo.mysql.com//mysql-apt-config_0.8.12-1_all.deb doesn't add repository. It downloads the .deb package which is then installed using dpkg -i
    – Kulfy
    Commented Mar 3, 2019 at 0:53
  • @Kulfy I followed this tutorial and nothing works at home tecmint.com/install-mysql-8-in-ubuntu
    – fgtr
    Commented Mar 3, 2019 at 1:25
  • What is the output of cat /etc/apt/sources.list.d/mysql.list?
    – Kulfy
    Commented Mar 3, 2019 at 10:46
  • @Kulfy This file is empty. Here is the result of "apt-key list" pastebin.com/7e5UcBhs
    – fgtr
    Commented Mar 4, 2019 at 6:38

2 Answers 2

18

Basically mysql-apt-config_0.8.12-1_all.deb is a package which adds MySQL's repository and key. It seems while installing this package you made wrong choices somewhere. You can do what that deb package do manually.

  • First of all create a new text file with sudo privileges:

    sudo nano /etc/apt/sources.list.d/mysql.list
    
  • Add these lines:

    deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-apt-config
    deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-8.0
    deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-tools
    #deb http://repo.mysql.com/apt/ubuntu/ bionic mysql-tools-preview
    deb-src http://repo.mysql.com/apt/ubuntu/ bionic mysql-8.0
    

    You can comment/uncomment the repository according to the packages required. Save and exit using Ctrl+X followed by Y.

  • If you're using some other version of Ubuntu, you should replace bionic with the codename of your currently installed Ubuntu system using sed.

    sudo sed -i 's/bionic/'$(lsb_release -sc)'/' /etc/apt/sources.list.d/mysql.list
    

    Then run

    sudo apt update
    
  • You'll get an error, like

    Err:1 http://repo.mysql.com/apt/ubuntu bionic InRelease                        
      The following signatures couldn't be verified because the public key is not available: NO_PUBKEY <some key value>
    
  • Add this key using

    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <key value>
    
  • Update and install MySQL

    sudo apt update
    sudo apt install mysql-server
    

Notes:

  1. Ubuntu 19.10 has MySQL 8.0 in its official repositories, therefore, there's no need to add the above sources unless latest updates are required.
  2. If the above method is followed and still APT installs MySQL v5.7, it may happen that MySQL has taken down the repository information for that release even before that release reaches the end of public support. See my other answer on Can't install MySQL 8 on Ubuntu 19.04 for details.
8
  • @Kufly Thank you, I will test it tonight. It's weird because I followed several blog posts and it does not work. Why it works for them? phoenixnap.com/kb/how-to-install-mysql-on-ubuntu-18-04 I restored my server, so I have to follow your answer ?
    – fgtr
    Commented Mar 4, 2019 at 7:46
  • @fgtr As I've stated in my answer as well as in comment, when I installed this package I was asked for choices 2-3 times. But since you have attached only 1 screenshot, it seems you made some wrong choices for which I'm not sure. You can try following my answer. It does exactly what that deb file does.
    – Kulfy
    Commented Mar 4, 2019 at 8:05
  • Thank you, I updated the screenshots of my question
    – fgtr
    Commented Mar 4, 2019 at 8:36
  • @fgtr Everything looks ok but still I'm not sure why it created empty mysql.list. You can try my answer and let me know if it helps. I've tried this before posting and everything worked fine.
    – Kulfy
    Commented Mar 4, 2019 at 8:59
  • Thanks it works, but if I update my database from version 5.7 to version 8.0 do I have to do mysql_upgrade? There are some explanations that I did not understand dev.mysql.com/doc/refman/8.0/en/mysql-upgrade.html
    – fgtr
    Commented Mar 5, 2019 at 2:12
0
$ sudo systemctl stop mysql
$ sudo apt remove mysql-*
$ sudo apt purge mysql-*
$ sudo apt autoremove
$ sudo dpkg -l | grep mysql | grep ii
$ wget https://repo.mysql.com//mysql-apt-config_0.8.12-1_all.deb
$ sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb
$ sudo sed -i 's/bionic/'$(lsb_release -sc)'/' /etc/apt/sources.list.d/mysql.list
$ sudo apt update

This sequence of commands worked for me. To check version before installation

sudo apt-cache policy mysql-server

But I still don't know how to delete other packages from cache.

To complete installation input

sudo apt install mysql-server

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .