How to upgrade to MySQL 8.0?
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 usingsed
.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:
- 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.
- 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.
Related videos on Youtube
fgtr
Updated on September 18, 2022Comments
-
fgtr over 1 year
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 :
I backed up my database.
-
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
-
I added the repository with the command :
$ wget https://repo.mysql.com//mysql-apt-config_0.8.12-1_all.deb
-
I installed the package with the command :
$ sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb
My problem :
-
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 ?
-
Admin about 5 years
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 usingdpkg -i
-
Admin about 5 years@Kulfy I followed this tutorial and nothing works at home tecmint.com/install-mysql-8-in-ubuntu
-
Admin about 5 yearsWhat is the output of
cat /etc/apt/sources.list.d/mysql.list
? -
Admin about 5 years@Kulfy This file is empty. Here is the result of "apt-key list" pastebin.com/7e5UcBhs
-
fgtr about 5 years@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 ?
-
Kulfy about 5 years@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.
-
fgtr about 5 yearsThank you, I updated the screenshots of my question
-
Kulfy about 5 years@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.
-
fgtr about 5 yearsThanks 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
-
Kulfy about 5 years@fgtr Not sure about that. I believe instructions are very much clear. You might like to run mysql_upgrade as they suggest.
mysql_upgrade --protocol=tcp -P 3306
must be sufficient. 3306 is the default port number. -
user9371654 about 5 yearsIf I want to follow your solution, do I have to remove the old MySQL as the OP?
-
Kulfy about 5 years@user9371654 Nope. Added the comment on your original post.