Kee*_*ees 5 mysql software-installation
使用 Kubuntu 17.04。我试图安装 mariadb,但没有成功,所以现在我试图恢复到 mysql。但是,当我尝试安装 mysql 时,它也不再工作:
~# apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server is already the newest version (5.7.19-0ubuntu0.17.04.1).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies.
mysql-server : Depends: mysql-server-5.7 but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
Run Code Online (Sandbox Code Playgroud)
然后我尝试了建议 --fix-broken:
~# apt-get --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
mysql-server-5.7
Suggested packages:
tinyca
The following NEW packages will be installed
mysql-server-5.7
0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.
5 not fully installed or removed.
Need to get 3,363 kB of archives.
After this operation, 50.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://gb.archive.ubuntu.com/ubuntu zesty-updates/main amd64 mysql-server-5.7 amd64 5.7.19-0ubuntu0.17.04.1 [3,363 kB]
Fetched 3,363 kB in 1s (3,049 kB/s)
Preconfiguring packages ...
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 304498 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb (--unpack):
subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)
现在有点卡住了。谁能帮我让我的系统再次稳定?
更新:尝试运行建议的命令,但这并没有解决问题:
~$ sudo service mysql stop
Failed to stop mysql.service: Unit mysql.service not loaded.
~$ sudo apt -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
mysql-server-5.7
Suggested packages:
tinyca
The following NEW packages will be installed
mysql-server-5.7
0 to upgrade, 1 to newly install, 0 to remove and 5 not to upgrade.
5 not fully installed or removed.
Need to get 0 B/3,363 kB of archives.
After this operation, 50.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Preconfiguring packages ...
(Reading database ... 304498 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb (--unpack):
subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
~$ sudo pkill mysqld
~$ sudo killall mysqld
mysqld: no process found
~$ sudo apt -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
mysql-server-5.7
Suggested packages:
tinyca
The following NEW packages will be installed
mysql-server-5.7
0 to upgrade, 1 to newly install, 0 to remove and 5 not to upgrade.
5 not fully installed or removed.
Need to get 0 B/3,363 kB of archives.
After this operation, 50.0 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Preconfiguring packages ...
(Reading database ... 304498 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb (--unpack):
subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/mysql-server-5.7_5.7.19-0ubuntu0.17.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)
我在 Ubuntu 17.04 上尝试从 MySQL 升级到 MariaDB 时遇到了同样的问题 无法安装 MariaDB,因为安装后脚本认为它无法启动服务器(超时错误但服务器已启动)。无法恢复到 MySQL,因为安装脚本认为它无法停止服务器,即使它实际上已停止。
使用 apt 卸载既困难又过度,因为它试图根据 MySQL 客户端库卸载每个包。
这是我恢复到 MySQL 然后升级到 MariaDB 的解决方案。
1) 检测所有 MariaDB 和 MySQL 包
apt search mariadb | grep "\[install"
Run Code Online (Sandbox Code Playgroud)
和
apt search mysql | grep "\[install"
Run Code Online (Sandbox Code Playgroud)
2) 强制卸载所有 MariaDB 和 MySQL 包(服务器、客户端、库)以清理混乱
sudo dpkg --force depends --purge <package> <package> ...
Run Code Online (Sandbox Code Playgroud)
3) 清理 /etc 和 /var/lib/mysql 中的剩余数据
注意:我首先尝试使用我的配置和数据文件安装 MariaDB 或 MySQL,但每次都失败。
sudo rm -rf /var/lib/mysql* /etc/mysql
Run Code Online (Sandbox Code Playgroud)
如果您想坚持使用 MySQL 并且在第一次 MariaDB 升级尝试时在 /var/lib/mysql-5.7 中没有 /var/lib/mysql 的副本,您应该只移动 /var/lib/mysql /var /lib/mysql-5.7 而不是删除它。
4) 修复系统
sudo apt-get --fix-broken install
sudo apt autoremove
sudo reboot
Run Code Online (Sandbox Code Playgroud)
5) 取回 MySQL 数据
--fix-broken 安装重新安装了一个干净的 MySQL(不是 MariaDB,因为 Ubuntu 似乎喜欢那样)。
sudo service mysql stop
mv /var/lib/mysql*5.7 /var/lib/mysql
sudo service mysql start
Run Code Online (Sandbox Code Playgroud)
如果您想转到第 6 步,您应该立即备份所有数据库。
6) 最后升级到 MariaDB
如果您已经有备份,则可以跳过第 5 步。
sudo apt-get install mariadb-server
Run Code Online (Sandbox Code Playgroud)
是的,这是我一开始尝试的,但这次有效!您可以重新创建您的数据库用户,然后恢复您的数据库,因为 MariaDB 不想升级 MySQL 5.7 基础。
| 归档时间: |
|
| 查看次数: |
7720 次 |
| 最近记录: |