Score:0

Upgrading MySQL from 5.7 to 8 on Ubuntu 18.04 (Bionic)

pk flag

Just as the title said. I tried to upgrade to MySQL 8 on my Ubuntu 18.04 box. I downloaded mysql-apt-config_0.8.12-1.all.deb,updated and then tried to upgrade. The following is the outcome from my terminal:

faiz@faiz ~ > sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb 
dpkg: error: dpkg frontend is locked by another process
faiz@faiz ~ > sudo dpkg -i mysql-apt-config_0.8.12-1_all.deb 
Selecting previously unselected package mysql-apt-config.
(Reading database ... 609461 files and directories currently installed.)
Preparing to unpack mysql-apt-config_0.8.12-1_all.deb ...
Unpacking mysql-apt-config (0.8.12-1) ...
Setting up mysql-apt-config (0.8.12-1) ...
Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)
OK
faiz@faiz ~ > sudo apt update
Ign:1 http://packages.linuxmint.com tara InRelease
Hit:2 http://packages.linuxmint.com tara Release                                                                                     
Ign:3 https://storage.googleapis.com/download.dartlang.org/linux/debian stable InRelease                                                                                      
Hit:5 http://repo.mysql.com/apt/ubuntu bionic InRelease                                                                                                                       
Hit:6 http://archive.canonical.com/ubuntu bionic InRelease                                                                                                                    
Get:7 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]                                                                                                   
Hit:8 http://packages.microsoft.com/repos/code stable InRelease                                                                                                               
Hit:9 https://storage.googleapis.com/download.dartlang.org/linux/debian stable Release                                                                                        
Hit:10 http://mirror.cogentco.com/pub/linux/ubuntu bionic InRelease                                                                                                           
Hit:11 https://download.mono-project.com/repo/ubuntu vs-bionic InRelease                                                                                                      
Ign:12 http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 InRelease                                                                                                    
Ign:13 http://repo.vivaldi.com/stable/deb stable InRelease                                                                                                                    
Hit:14 http://repo.vivaldi.com/stable/deb stable Release                                                                                                                      
Hit:15 http://mirror.cogentco.com/pub/linux/ubuntu bionic-updates InRelease                                                                                                   
Hit:16 https://deb.opera.com/opera-stable stable InRelease                                                                                                                    
Hit:17 https://deb.nodesource.com/node_12.x bionic InRelease                                                                                                                  
Hit:18 http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release                                                                                                     
Hit:19 http://mirror.cogentco.com/pub/linux/ubuntu bionic-backports InRelease                                                                          
Hit:20 http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic InRelease                                                       
Hit:21 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease                                                                  
Hit:23 http://ppa.launchpad.net/malteworld/ppa/ubuntu bionic InRelease                                                                
Hit:25 http://ppa.launchpad.net/noobslab/macbuntu/ubuntu bionic InRelease      
Hit:26 http://ppa.launchpad.net/yannubuntu/boot-repair/ubuntu bionic InRelease 
Fetched 88.7 kB in 2s (45.9 kB/s)                   
Reading package lists... Done
Building dependency tree       
Reading state information... Done
5 packages can be upgraded. Run 'apt list --upgradable' to see them.
faiz@faiz ~ > sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  mysql-client mysql-common mysql-server mysql-testsuite
The following packages will be upgraded:
  mysql-apt-config
1 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
4 not fully installed or removed.
Need to get 35.5 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://repo.mysql.com/apt/ubuntu bionic/mysql-apt-config amd64 mysql-apt-config all 0.8.16-1 [35.5 kB]
Fetched 35.5 kB in 0s (129 kB/s)            
Preconfiguring packages ...
(Reading database ... 609466 files and directories currently installed.)
Preparing to unpack .../mysql-apt-config_0.8.16-1_all.deb ...
Unpacking mysql-apt-config (0.8.16-1) over (0.8.12-1) ...
Setting up mysql-apt-config (0.8.16-1) ...
Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)
OK
Setting up mysql-server-5.7 (5.7.35-0ubuntu0.18.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
Unable to determine if daemon is running: No such file or directory
Warning: Unable to start the server. Please restart MySQL and run mysql_upgrade to ensure the database is ready for use.
Unable to determine if daemon is running: No such file or directory
Warning: Unable to start the server.
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2021-08-17 11:45:50 CDT; 6ms ago
  Process: 12521 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
  Process: 12512 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 28432 (code=exited, status=1/FAILURE)
dpkg: error processing package mysql-server-5.7 (--configure):
 installed mysql-server-5.7 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report was written because the error message indicates its a followup error from a previous failure.
                                                                                                          dpkg: dependency problems prevent configuration of mysql-testsuite-5.7:
 mysql-testsuite-5.7 depends on mysql-server-5.7 (= 5.7.35-0ubuntu0.18.04.1); however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-testsuite-5.7 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mysql-testsuite:
 mysql-testsuite depends on mysql-testsuite-5.7; however:
  Package mysql-testsuite-5.7 is not configured yet.

dpkg: error processing package mysql-testsuite (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          No apport report written because MaxReports is reached already
                                                                                                                                                                        Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
 mysql-testsuite-5.7
 mysql-testsuite
E: Sub-process /usr/bin/dpkg returned an error code (1)
faiz@faiz ~ > sudo apt upgrade

I have tried many times to find a solution to this issue, but none was successful.

Score:0
ma flag

I ran into a similar issue when I was upgrading Ubuntu from 18.04 to 20.04. What solved it for me was to completely remove MySQL by running the following command

Make sure you have a backup of your databases and config file

sudo apt-get purge mysql\* libmysql\*

Then, I went around made sure that there was no trace of mysql or its configs left in:

  • /var/lib/mysql
  • /etc/mysql

Then I reinstalled and loaded my backed up databases.

pk flag
Thank you for the answer. Which version did you install after completely removing MySQL?
nicks6853 avatar
ma flag
Install the version you were trying to upgrade to, so in your case it would be 8
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.