0%

【解决】【解决】Ubuntu apt upgrade时遇到 This installation of MySQL is already错误

标题写不下,在下面补充
This installation of MySQL is already upgraded to ****, use –force if you still need to run mysql_upgrade

这次是由于在升级过程中遇到的,只能进行强制关闭
用过很多方法都不能解决,按照下面的步骤即可。

1. 首先备份你的数据库

1
sudo cp -avt /your/backup/directory /var/lib/mysql /etc/mysql/mysql.conf.d

2. 删除mysql文件

1
sudo rm -rv /etc/mysql

3. 卸载mysql

1
sudo apt purge mysql-server mysql-server-5.7 mysql-server-core-5.7 mysql-client-5.7 mysql-client-core-5.7

4. 创建文件夹

1
sudo mkdir -p /etc/mysql/mysql.conf.d

5. 安装mysql

1
sudo apt install mysql-server

6. 停止Mysql服务

1
sudo service mysql stop

7. 还原数据库文件及设置

1
2
3
sudo cp -a /your/backup/directory/mysql /var/lib   
sudo cp /your/backup/directory/my.cnf /etc/mysql
sudo cp -a /your/backup/directory/mysql.conf.d /etc/mysql

8. 启动mysql服务

1
sudo service mysql start