我的伺服器硬碟崩潰了,不幸的是我的 MySQL 備份(每天一次)丟失了一些重要數據,但我有資料夾中的檔案/var/lib/mysql
。
在 Ubuntu 16.4 上的新安裝中,我成功安裝了 MySQL 並嘗試將檔案從舊安裝複製/var/lib/mysql
到新安裝,但我遇到了問題並決定重新安裝 MySQL。
我已經關注了這些說明完全卸載並重新安裝 MySQL,但是現在當我嘗試安裝 MySQL 時,我看到以下輸出:
user@computer:~$ sudo apt-get install mysql-server mysql-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed
mysql-client mysql-server
0 to upgrade, 2 to newly install, 0 to remove and 0 not to upgrade.
Need to get 0 B/20.2 kB of archives.
After this operation, 317 kB of additional disk space will be used.
Selecting previously unselected package mysql-client.
(Reading database ... 213412 files and directories currently installed.)
Preparing to unpack .../mysql-client_5.7.12-0ubuntu1_all.deb ...
Unpacking mysql-client (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.12-0ubuntu1_all.deb ...
Unpacking mysql-server (5.7.12-0ubuntu1) ...
Setting up mysql-client (5.7.12-0ubuntu1) ...
Setting up mysql-server (5.7.12-0ubuntu1) ...
然而:
root
沒有出現任何類型的提示,詢問資料庫配置或為 MySQL使用者設定密碼- 沒有
/etc/mysql/
建立資料夾 - 沒有
/var/lib/mysql/
建立資料夾
嘗試卸載時mysql-common
,我看到以下錯誤:
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies.
mysql-client : Depends: mysql-client-5.7 but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
如何根據提示和正確的資料夾再次正確安裝 MySQL,或者如何找到預設值/etc/mysql/
和/var/lib/mysql/
資料夾內容以手動設定它?
答案1
以下命令幫助我卸載並重新安裝 MySQL(按此順序,儘管我不知道其中一些命令是否多餘):
sudo apt-get install mysql-client
sudo apt-get install mysql-server
sudo apt-get purge dbconfig-mysql
sudo apt-get purge mysql-common
sudo apt-get install mysql-server
sudo apt-get install mysql-client