在 Ubuntu 18.04(Bionic)上将 MySQL 从 5.7 升级到 8

在 Ubuntu 18.04(Bionic)上将 MySQL 从 5.7 升级到 8

正如标题所述。我尝试在我的 Ubuntu 18.04 机器上升级到 MySQL 8。我下载mysql-apt-config_0.8.12-1.all.deb、更新,然后尝试升级。以下是我的终端结果:

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

我曾多次尝试寻找该问题的解决方案,但均未成功。

答案1

我在将 Ubuntu 从 18.04 升级到 20.04 时遇到了类似的问题。我解决这个问题的方法是运行以下命令完全删除 MySQL

确保备份了数据库和配置文件

sudo apt-get purge mysql\* libmysql\*

然后,我四处检查,确保没有留下任何 mysql 或其配置的痕迹:

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

然后我重新安装并加载了我备份的数据库。

相关内容